local extension = Package("teyvat_travel_log")
extension.extensionName = "zenless__teyvat"
local U = require "packages/utility/utility"

--- 明置牌可见技能 
--- 本扩村规：明置可见只针对手牌区，装备区基本都是可见牌（明置上标记就好），移出游戏外的就不另外监听了
local tey_mingzhi = fk.CreateVisibilitySkill{
  name = '#tey_mingzhi',
  global = true,
  frequency = Skill.Compulsory,
  card_visible = function(self, player, card)
    if Fk:currentRoom():getCardArea(card) == Card.PlayerHand and
    card:getMark("@@ShownCards-inhand") > 0 then
      return true
    end
  end
}
Fk:addSkill(tey_mingzhi)

--- 暗置牌无效技能 （奥藏效果绝赞准备中，根据明置定义，场上的牌默认明置，所以得用点反向思路，比如暗置场上的牌）
--- 本扩村规：暗置不管是奥藏操作还是被其他效果暗置，牌在场上就无效（本来奥藏的牌也就是转化使用，只有判定阶段才能回手额外行动）

--- 重新隐匿 （直接搬了封侯的代码，主要是跨服务器没有封侯包报错就老实了，这里鸣谢封侯的代码大佬）
---@param player ServerPlayer @ 目标角色
IntoHidden = function (player)
  local room = player.room
  room:sendLog({
    type = "#IntoHidden",
    from = player.id,
  })
  local skills = "hidden_skill&"
  room:setPlayerMark(player, "__hidden_general", player.general)
  for _, s in ipairs(Fk.generals[player.general]:getSkillNameList(true)) do
    if player:hasSkill(s, true) then
      skills = skills.."|-"..s
    end
  end
  if player.deputyGeneral ~= "" then
    room:setPlayerMark(player, "__hidden_deputy", player.deputyGeneral)
    for _, s in ipairs(Fk.generals[player.deputyGeneral]:getSkillNameList(true)) do
      if player:hasSkill(s, true) then
        skills = skills.."|-"..s
      end
    end
  end
  player.general = table.random({"hiddenone", "tey__Fatui"}, 1)[1]
  player.gender = General.Male
  room:broadcastProperty(player, "gender")
  if player.deputyGeneral ~= "" then
    player.deputyGeneral = ""
  end
  player.kingdom = table.random({"Void", "jin"}, 1)[1]
  room:setPlayerMark(player, "__hidden_record",
  {
    maxHp = player.maxHp,
    hp = player.hp,
  })
  player.maxHp = 1
  player.hp = 1
  for _, property in ipairs({"general", "deputyGeneral", "kingdom", "maxHp", "hp"}) do
    room:broadcastProperty(player, property)
  end
  room:handleAddLoseSkills(player, skills, nil, false, true)
end

-- 将一张牌置于一名角色的区域内的通用技能，幽蝶智慧（并非，超级难用），可以根据以下额外数据定制技能：<br>
-- all_choices_exclu，依次为："PlaceEquip"置入装备区（装备牌），"PlaceEquipForce"置入装备区（装备牌，替换原装备），<br>
-- "TrueDelay"置入判定区（真延时），"AsLe"红乐，"AsBing"黑兵，"AsPremeditate"蓄谋，"ToHand"手牌区，<br>
-- 特别地，主服现在只有蓄谋牌，但是没有任何蓄谋的有关的局内效果，蓄谋选项目前只在扶摇服可用<br>
-- only_card，指定的任意张牌，不填默认为玩家区域内的牌，返回id数组 <br>
-- only_target，指定的任意名角色，不填默认为所有角色，返回id数组 <br>
-- expand_pile，如果牌不在角色区域内（如弃牌堆，处理区）需填，返回id数组 <br>
local teyvat__cardplace = fk.CreateActiveSkill{
  name = "teyvat__cardplace",
  card_num = 1,
  target_num = 1,
  interaction = function(self)
    local all_choices
    if self.all_choices_exclu ~= nil then
      all_choices = self.all_choices_exclu
    else
      all_choices = {"PlaceEquip", "PlaceEquipForce", "TrueDelay", "AsLe", "AsBing", "AsPremeditate", "ToHand"}
    end
    if (not Fk.all_card_types["rfenghou__premeditate"]) then
      table.removeOne(all_choices, "AsPremeditate")
    end
    return UI.ComboBox {choices = all_choices}
  end,
  card_filter = function(self, to_select, selected, player)
    if #selected == 0 and table.contains(self.only_card ~= nil and self.only_card or player:getCardIds("hej"), to_select) then
      local card = Fk:getCardById(to_select, true)
      if self.interaction.data == "PlaceEquip" or self.interaction.data == "PlaceEquipForce" then
        return card.type == Card.TypeEquip
    elseif self.interaction.data == "TrueDelay" then
        return card.sub_type == Card.SubtypeDelayedTrick
    elseif self.interaction.data == "AsLe" then
        return card.color == Card.Red and card.sub_type ~= Card.SubtypeDelayedTrick
    elseif self.interaction.data == "AsBing" then
        return card.color == Card.Black and card.sub_type ~= Card.SubtypeDelayedTrick
    elseif self.interaction.data == "AsPremeditate" or self.interaction.data == "ToHand" then
        return true
      end
    return true
    end
  end,
  target_filter = function(self, to_select, selected, selected_cards, extra_data, player)
    if #selected == 0 and #selected_cards == 1 then
      local card = Fk:getCardById(selected_cards[1], true)
      local target = Fk:currentRoom():getPlayerById(to_select)
      if self.only_target ~= nil and not table.contains(self.only_target, to_select) then 
        return false
      else
        if self.interaction.data == "PlaceEquip" then
          return target:hasEmptyEquipSlot(card.sub_type)
        elseif self.interaction.data == "PlaceEquipForce" then
          return U.canMoveCardIntoEquip(target, selected_cards[1], true)
        elseif self.interaction.data == "TrueDelay" then
          return not target:isProhibited(target, card)
        elseif self.interaction.data == "AsLe" then
          return not target:isProhibited(target, Fk:cloneCard("indulgence"))
        elseif self.interaction.data == "AsBing" then
          return not target:isProhibited(target, Fk:cloneCard("supply_shortage"))
        elseif self.interaction.data == "AsPremeditate" then
          return not table.contains(target.sealedSlots, Player.JudgeSlot)
        elseif self.interaction.data == "ToHand" then
          return true
        end
      return true
      end
    end
  end,
  feasible = function (self, selected, selected_cards)
    return #selected_cards == 1 and #selected == 1
  end,
}
Fk:addSkill(teyvat__cardplace)
Fk:loadTranslationTable{
  ["teyvat__cardplace"] = "放置",
  ["PlaceEquip"] = "（装备）置入装备区空栏",
  ["PlaceEquipForce"] = "（装备）置于装备区并替换原装备",
  ["TrueDelay"] = "（延时锦囊）置入判定区",
  ["AsLe"] = "（红色非延时锦囊）当乐不思蜀使用",
  ["AsBing"] = "（黑色非延时锦囊）当兵粮寸断使用",
  ["AsPremeditate"] = "当蓄谋牌置入判定区",
  ["ToHand"] = "置入手牌区",
}

--这里就是专属概念的翻译表，方便玩家检索与理解（并非方便理解）新概念
Fk:loadTranslationTable{
  ["tey_mingzhi"] = "明置",
  [":tey_mingzhi"] = "处于角色区域中的明置牌（有”明置“标记的牌）对所有角色可见。",
  ["tey_anzhi"] = "暗置",
  [":tey_anzhi"] = "处于角色区域中的暗置牌（有”明置“标记的牌）只对区域所属角色可见。场上的暗置牌无效。",
  ["@@ShownCards-inhand"] = "明置",
  ["@@ShownCards-inhand-round"] = "明置",
  ["@@ShownCards-inhand-turn"] = "明置",
  ["@@ShownCards-inhand-phase"] = "明置",
  ["@@HiddenCards"] = "暗置", --通常是针对场上的牌，需要在卡牌移动时检测之
  ["renew_skill_href"] = "重置技描述中{}包含的选项限选择一次，相同{}中的选项均选择过后，均视为未选择过。<br>"..
  "注意：不同{}包含的选项分别计算。",
  ["ready_skill_href"] = "蓄势技每局限发动一次，可以通过以下方式重置：出牌阶段弃置三张牌（此牌数即为“重置牌数”），"..
  "选择一个本轮未发动过的蓄势技重置；牌堆洗切后重置所有蓄势技。",
  ["purecard_href"] = "纯实体牌是指状态正常的实体游戏牌（即不参与转化，视为）<br>"..
  "不因纯实体牌造成伤害的途径有：视为牌，转化牌，虚拟牌，技能伤害。",
  ["transform_skill_href"] = "其实就是多项转换，但是因为沟槽的卢弈曹肇无法和多项转换互动"..
  "（实际上也只能处理成发动后切换标记的触发/主动/视为技）",
  ["#IntoHidden"] = "%from 进入隐匿状态",
  ["IntoHidden_href"] = "记录当前的体力上限和体力值，失去当前武将牌上的所有技能，将武将替换为隐匿将。再次登场后，"..
  "将体力上限和体力值调整为记录值，武将替换回隐匿前的武将，获得武将牌上所有的技能。",
}

--这里开始就是提瓦特旅行日志武将代码了，首先添加势力注释
Fk:loadTranslationTable{
  ["zenless__teyvat"] = "空荧哲铃",
  ["teyvat_travel_log"] = "提瓦特旅行日志",
  ["Mondstadt"] = "蒙德",
  ["Liyue"] = "璃月",
  ["Inazuma"] = "稻妻",
  ["Sumeru"] = "须弥",
  ["Fontaine"] = "枫丹",
  ["Natlan"] = "纳塔",
  ["tey"] = "提瓦特",
}

--加入神将开局可选势力，转换技，阳：若更新大版本号为“扶摇”则不注释；阴：若大版本号为“逐云阁”则注释
--Fk:appendKingdomMap("god", {"Mondstadt"})
--Fk:appendKingdomMap("god", {"Liyue"})
--Fk:appendKingdomMap("god", {"Fontaine"})
--Fk:appendKingdomMap("god", {"Natlan"})

--武将列表，按势力进行分类排序 隐藏的将除非参与测试，正常对局别乱点出来，跳了什么bug我可不负责

--已完成 待处理：标记杀的逻辑需要优化，无法在使用时直接看到拥有者
local Amber = General(extension, "tey__Amber", "Mondstadt", 3, 3, General.Female) 
--已完成
local Lisa = General(extension, "tey__Lisa", "Mondstadt", 3, 3, General.Female)
--已完成 待处理：对专一目标使用牌的逻辑亟待优化，可能要等到OL薛灵芸出来，再跟着把对其他角色用装备也弄出来
local Noelle = General(extension, "tey__Noelle", "Mondstadt", 3, 3, General.Female) 
Noelle.shield = 2
--已完成
local Barbara = General(extension, "tey__Barbara", "Mondstadt", 3, 3, General.Female)
--已完成
local Diluc = General(extension, "tey__Diluc", "Mondstadt", 4, 4, General.Male)
--已完成
local Rosaria = General(extension, "tey__Rosaria", "Mondstadt", 4, 4, General.Female)
--已完成 待处理：偶发使用虚拟牌后无法获取对应实体牌，在联动青龙刀折进飙发等情况下多见
local Keqing = General(extension, "tey__Keqing", "Liyue", 3, 3, General.Female) 
--未完成
local Xingqiu = General(extension, "tey__Xingqiu", "Liyue", 3, 3, General.Male)
Xingqiu.shield = 1
--未完成
local Yelan = General(extension, "tey__Yelan", "Liyue", 3, 4, General.Female) 
Yelan.hidden = true
--已完成
local Xinyan = General(extension, "tey__Xinyan", "Liyue", 4, 4, General.Female) 
--已完成
local Xiao = General(extension, "tey__Xiao", "Liyue", 2, 4, General.Male) 
--已完成
local Yaoyao = General(extension, "tey__Yaoyao", "Liyue", 4, 4, General.Female) 
--已完成
local Jiaming = General(extension, "tey__Jiaming", "Liyue", 4, 4, General.Male) 
--已完成
local Lanyan = General(extension, "tey__Lanyan", "Liyue", 3, 3, General.Female)
--已完成
local RaidenShogun = General(extension, "tey__RaidenShogun", "Inazuma", 4, 4, General.Female) 
--未完成 无对象限制的检测有问题！
local Nirou = General(extension, "tey__Nirou", "Sumeru", 3, 3, General.Female) 
Nirou.hidden = true
--已完成
local Cyno = General(extension, "tey__Cyno", "Sumeru", 4, 4, General.Male) 
--已完成
local Dehya = General(extension, "tey__Dehya", "Sumeru", 4, 4, General.Female)
--已完成
local Layla = General(extension, "tey__Layla", "Sumeru", 3, 3, General.Female)
--已完成
local Charlotte = General(extension, "tey__Charlotte", "Fontaine", 3, 3, General.Female) 
--已完成 待重做
local Navia = General(extension, "tey__Navia", "Fontaine", 4, 4, General.Female)
Navia.hidden = true
--已完成 
local Chevreuse = General(extension, "tey__Chevreuse", "Fontaine", 4, 4, General.Female) 
--已完成
local Clorinde = General(extension, "tey__Clorinde", "Fontaine", 4, 4, General.Female) 
--已完成
local Sigewinne = General(extension, "tey__Sigewinne", "Fontaine", 3, 5, General.Female) 
--已完成 
local Kachina = General(extension, "tey__Kachina", "Natlan", 4, 4, General.Female) 
--已完成
local Mualani = General(extension, "tey__Mualani", "Natlan", 3, 3, General.Female) 
--未完成
local Xilonen = General(extension, "tey__Xilonen", "Natlan", 3, 3, General.Female) 
Xilonen.shield = 1
Xilonen.hidden = true
--已完成
local Chasca = General(extension, "tey__Chasca", "Natlan", 4, 4, General.Female) 
--已完成 
local Mavuika = General(extension, "tey__Mavuika", "Natlan", 4, 4, General.Female) 
Mavuika.hidden = true
--已完成 
local Citlali = General(extension, "tey__Citlali", "Natlan", 3, 3, General.Female) 
--未完成
local Fatui = General(extension, "tey__Fatui", "Void", 1, 1, General.Female) 
Fatui.hidden = true

--废案，但是辛苦写的代码还是留着，万一以后有所启发或者可以照抄
--local SPShenhe = General(extension, "tey__SPShenhe", "Liyue", 4, 4, General.Female) 

local tey__langzhao = fk.CreateTriggerSkill{
  name = "tey__langzhao",
  anim_type = "offensive",
  events = {fk.EventPhaseStart},
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(self) and player.phase == Player.Finish
  end,
  on_use = function(self, event, target, player, data)
    local mark = player:getTableMark("@$tey__langzhao")
    for _, p in ipairs(player.room:getAllPlayers()) do
      if (player:inMyAttackRange(p) or p == player) and not p:isKongcheng() then
        p:showCards(p:getCardIds("h"))
        for _, id in ipairs(p:getCardIds("h")) do
          if Fk:getCardById(id).trueName == "slash" then
            table.insertIfNeed(mark, id)
          end
        end
      end
    end
    player.room:setPlayerMark(player, "@$tey__langzhao", mark)
    local _, dat = player.room:askForUseActiveSkill(player, "tey__langzhao_active", "#tey__langzhao-ask", true)
    if dat then
    local card = Fk.skills["tey__langzhao_active"]:viewAs(dat.cards)
    local use = {
    from = player.id,
    tos = table.map(dat.targets, function(id) return {id} end),
    card = card,
    extraUse = true,}
    player.room:useCard(use)
    end
    local slash = table.filter(player:getCardIds("h"), function (id)
      return Fk:getCardById(id).trueName == "slash"
    end)
    if #slash == 0 then
      for _, p in ipairs(player.room:getAllPlayers()) do
        if (player:inMyAttackRange(p) or p == player) and #table.filter(p:getCardIds("h"), function (id)
          return Fk:getCardById(id).trueName == "slash"
        end) == 0 then
          p:drawCards(1, self.name, nil)
        end
      end
    else
      for _, p in ipairs(player.room:getAllPlayers()) do
        if (player:inMyAttackRange(p) or p == player) and #table.filter(p:getCardIds("h"), function (id)
          return Fk:getCardById(id).trueName == "slash"
        end) > 0 then
          p:drawCards(1, self.name, nil)
        end
      end
    end
    for _, p in ipairs(player.room:getAllPlayers()) do
      for _, id in ipairs(p:getCardIds("h")) do
        table.removeOne(mark, id)
      end
    end
    player.room:setPlayerMark(player, "@$tey__langzhao", 0)
  end,

}

local tey__langzhao_active = fk.CreateViewAsSkill{
  name = "tey__langzhao_active",
  pattern = ".",
  anim_type = "special",
  prompt = "#tey__langzhao_active",
  expand_pile = function() return Self:getTableMark("@$tey__langzhao") end,
  card_filter = function(self, to_select, selected)
    return #selected == 0 and table.contains(Self:getTableMark("@$tey__langzhao"), to_select)
  end,
  view_as = function(self, cards)
    if #cards ~= 1 then return end
    return Fk:getCardById(cards[1])
    end,
  before_use = function(self, player, use)
    use.extraUse = true
  end,
}

local tey__jiaoxin = fk.CreateActiveSkill{
  name = "tey__jiaoxin",
  anim_type = "control",
  prompt = "#tey__jiaoxin-active",
  target_num = 1,
  card_num = 0,
  can_use = function(self, player)
    return player:usedSkillTimes(self.name, Player.HistoryPhase) == 0
  end,
  card_filter = Util.FalseFunc,
  target_filter = function(self, to_select, selected)
    return #selected == 0 and to_select ~= Self.id and not Fk:currentRoom():getPlayerById(to_select):isKongcheng()
  end,
  on_use = function(self, room, effect)
    local player = room:getPlayerById(effect.from)
    local target = room:getPlayerById(effect.tos[1])
    U.viewCards(player, target:getCardIds("h"), self.name)
    local choices = {"cancel"}
    if not target:isNude() then
      table.insert(choices, "tey__jiaoxin_ask")
    end
    if not player:isNude() then
      table.insert(choices, "tey__jiaoxin_give")
    end
    local choice = room:askForChoice(player, choices, self.name, "#jiaoxin-choice:")
    if choice == "tey__jiaoxin_ask" then
      local card = room:askForCard(target, 1, 1, true, self.name, false, ".", "#jiaoxin-ask:")
      room:obtainCard(player.id, card[1], false, fk.ReasonGive)
    elseif choice == "tey__jiaoxin_give" then
      local card = room:askForCard(player, 1, 1, true, self.name, false, ".", "#jiaoxin-give:")
      room:obtainCard(target.id, card[1], false, fk.ReasonGive)
    elseif choice == "cancel" then
      return false
    end
  end,
}

local tey__jiaoxin_trigger = fk.CreateTriggerSkill{
  name = "#tey__jiaoxin_trigger",
  anim_type = "masochism",
  events = {fk.Damaged},
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(self) and data.card and data.card.trueName == "slash"
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
    local targets = table.filter(room:getOtherPlayers(player), function(p)
      return not p:isKongcheng()
    end)
    local to = room:askForChoosePlayers(player, table.map(targets, Util.IdMapper), 1, 1, "#tey__jiaoxin-active", self.name, true)
    if #to > 0 then
      self.cost_data = to
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    player:broadcastSkillInvoke("tey__jiaoxin")
    local target = room:getPlayerById(self.cost_data[1])
    U.viewCards(player, target:getCardIds("h"), self.name)
    local choices = {"cancel"}
    if not target:isNude() then
      table.insert(choices, "tey__jiaoxin_ask")
    end
    if not player:isNude() then
      table.insert(choices, "tey__jiaoxin_give")
    end
    local choice = room:askForChoice(player, choices, self.name, "#jiaoxin-choice:")
    if choice == "tey__jiaoxin_ask" then
      local card = room:askForCard(target, 1, 1, true, self.name, false, ".", "#jiaoxin-ask:")
      room:obtainCard(player.id, card[1], false, fk.ReasonGive)
    elseif choice == "tey__jiaoxin_give" then
      local card = room:askForCard(player, 1, 1, true, self.name, false, ".", "#jiaoxin-give:")
      room:obtainCard(target.id, card[1], false, fk.ReasonGive)
    elseif choice == "cancel" then
      return false
    end
  end,
}

Fk:addSkill(tey__langzhao_active)
Amber:addSkill(tey__langzhao)
tey__jiaoxin:addRelatedSkill(tey__jiaoxin_trigger)
Amber:addSkill(tey__jiaoxin)

Fk:loadTranslationTable{
  ["tey__Amber"] = "安柏", 
  ["#tey__Amber"] = "煦风渡浪英",
  ["cv:tey__Amber"] = "蔡书瑾",
  ["illustrator:tey__Amber"] = "砂原マイカ",
  ["designer:tey__Amber"] = "幽蝶化烬",

  ["tey__langzhao"] = "朗照",
  [":tey__langzhao"] = "结束阶段，你可以与攻击范围内所有角色各展示手牌，且你可以使用所有展示牌中的一张【杀】，然后若你的手牌中有/没有【杀】，此项与你相同的角色各摸一张牌。",
  ["tey__jiaoxin"] = "交心",
  [":tey__jiaoxin"] = "出牌阶段限一次，或你受到【杀】的伤害后，你可以观看一名其他角色的手牌，然后可以选择一项：交给其一张牌；或令其交给你一张牌。",
  ["tey__langzhao_active"] = "朗照",
  ["@$tey__langzhao"] = "朗照",
  ["#tey__langzhao-ask"] = "发动 朗照，请使用其中的一张【杀】。",
  ["#tey__langzhao_active"] = "发动 朗照，请使用其中的一张【杀】。",
  ["#tey__jiaoxin-active"] = "发动 交心，请观看一名其他角色手牌，然后可以交给其或令其交给你一张牌。",
  ["tey__jiaoxin_ask"] = "令其交给你一张牌",
  ["tey__jiaoxin_give"] = "交给其一张牌",
  ["cancel"] = "取消",
  ["#jiaoxin-choice"] = "交心，可以交给其或令其交给你一张手牌。",
  ["#jiaoxin-ask"] = "交心，请交给安柏一张手牌。",
  ["#jiaoxin-give"] = "交心，交给其一张手牌。",
  ["#tey__jiaoxin_trigger"] = "交心",

  ["$tey__langzhao1"] = "侦察骑士，发现目标！",
  ["$tey__langzhao2"] = "就算是你，比赛我也不会放水！",
  ["$tey__jiaoxin1"] = "兔兔伯爵，出击！",
  ["$tey__jiaoxin2"] = "交给我吧！",
  ["~tey__Amber"] = "这次我…输了啊…",
}

local tey__huiqiang_jinkSkill = fk.CreateActiveSkill{
  name = "tey__huiqiang_jinkSkill",
  prompt = "#jink_skill",
  target_num = 1,
  mod_target_filter = Util.TrueFunc,
  can_use = function(self, player, card)
    return not player:isProhibited(player, card)
  end,
  on_use = function(self, room, cardUseEvent)
    if not cardUseEvent.tos or #TargetGroup:getRealTargets(cardUseEvent.tos) == 0 then
      cardUseEvent.tos = { { cardUseEvent.from } }
    end
  end,
  on_effect = function(self, room, effect)
    local target = room:getPlayerById(effect.to)
    if target.dead then return end
    target:drawCards(1, "jink")
  end
}
tey__huiqiang_jinkSkill.cardSkill = true
Fk:addSkill(tey__huiqiang_jinkSkill)
local tey__huiqiang = fk.CreateTriggerSkill{
  name = "tey__huiqiang",
  anim_type = "drawcard",
  mute = true,
  events = {fk.TargetSpecified, fk.TargetConfirmed},
  can_trigger = function(self, event, target, player, data)
    if data.card and data.card.type ~= Card.TypeBasic and player:hasSkill(self)
    and player:usedSkillTimes(self.name, Player.HistoryTurn) == 0 and target == player then
      local to = player.room:getPlayerById(data.to)
      if event == fk.TargetSpecified then
        return not to.dead and U.isOnlyTarget(to, data, event)
      else
        return not player.dead and U.isOnlyTarget(player, data, event)
      end
    end
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
    local all_names , names = player:getTableMark("@$tey__huiqiang"), {}
    for i = 1, 3, 1 do
      local card_name = all_names[i]
      all_names[i] = "tey__huiqiang_index:::"..i..":"..card_name
      if player:getMark("@@tey__huiqiang"..i) == 1 then
        table.insert(names, all_names[i])
      end
    end
    if #names == 0 then return end
    local results = room:askForChoices(
      player,
      names,
      1,
      1, 
      self.name,
      "#tey__huiqiang_tranform"
    )
    if #results == 0 then
      return false
    end
    self.cost_data = results[1]
    return true
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    data.extra_data = data.extra_data or {}
      data.extra_data.tey__huiqiang = {player.id}
    local nameChosen = self.cost_data
    local use = room.logic:getCurrentEvent():findParent(GameEvent.UseCard, true)
    player:broadcastSkillInvoke(self.name, math.random(3))
    if use ~= nil then
      if string.split(nameChosen, ":")[5] == "jink" then
      local new_card = Fk:cloneCard(string.split(nameChosen, ":")[5], data.card.suit, data.card.number)
      local c = table.simpleClone(data.card)
      for k, v in pairs(c) do
        if new_card[k] == nil then
          new_card[k] = v
        end
      end
      if data.card:isVirtual() then
        new_card.subcards = data.card.subcards
      else
        new_card.id = data.card.id
      end
      new_card.skillNames = data.card.skillNames
      new_card.skill = tey__huiqiang_jinkSkill
      data.card = new_card
      use.data[1].card = new_card
      else
      local new_card = Fk:cloneCard(string.split(nameChosen, ":")[5], data.card.suit, data.card.number)
      local c = table.simpleClone(data.card)
      for k, v in pairs(c) do
        if new_card[k] == nil then
          new_card[k] = v
        end
      end
      if data.card:isVirtual() then
        new_card.subcards = data.card.subcards
      else
        new_card.id = data.card.id
      end
      new_card.skillNames = data.card.skillNames
      new_card.skill = Fk.skills[""..string.split(nameChosen, ":")[5].."_skill"]
      data.card = new_card
      use.data[1].card = new_card
      end
    end
    if player:getMark("@@tey__huiqiang1") == 1 then
      room:setPlayerMark(player, "@@tey__huiqiang1", 0)
      room:setPlayerMark(player, "@@tey__huiqiang3", 0)
      room:setPlayerMark(player, "@@tey__huiqiang2", 1)
    elseif player:getMark("@@tey__huiqiang2") == 1 then
      room:setPlayerMark(player, "@@tey__huiqiang1", 0)
      room:setPlayerMark(player, "@@tey__huiqiang2", 0)
      room:setPlayerMark(player, "@@tey__huiqiang3", 1)
    elseif player:getMark("@@tey__huiqiang3") == 1 then
      room:setPlayerMark(player, "@@tey__huiqiang3", 0)
      room:setPlayerMark(player, "@@tey__huiqiang2", 0)
      room:setPlayerMark(player, "@@tey__huiqiang1", 1)
      local all_names , names = player:getTableMark("@$tey__huiqiang"), {}
      for i = 1, 3, 1 do
        local card_name = all_names[i]
        all_names[i] = "tey__huiqiang_index:::"..i..":"..card_name
        if Fk:cloneCard(card_name).trueName ~= "slash" and Fk:cloneCard(card_name).trueName ~= "jink" then
          table.insert(names, all_names[i])
        end
      end
      if #names == 0 then return end
      local result = room:askForChoices(
        player,
        names,
        1,
        1, 
        self.name,
        "#tey__huiqiang_tranform_slash",
        false
      )
      player:broadcastSkillInvoke(self.name, 4)
      local mark = player:getTableMark("@$tey__huiqiang")
      mark[tonumber(string.split(result[1], ":")[4])] = "thunder__slash"
      room:setPlayerMark(player, "@$tey__huiqiang", mark)
    end
  end,

  on_acquire = function (self, player, is_start)
    local room = player.room
      room:setPlayerMark(player, "@@tey__huiqiang1", 1)
      room:setPlayerMark(player, "@@tey__huiqiang2", 0)
      room:setPlayerMark(player, "@@tey__huiqiang3", 0)
      room:setPlayerMark(player, "tey__huiqiang1", "ex_nihilo")
      room:setPlayerMark(player, "tey__huiqiang2", "foresight")
      room:setPlayerMark(player, "tey__huiqiang3", "reinforcement")
      room:setPlayerMark(player, "@$tey__huiqiang", {"ex_nihilo", "foresight", "reinforcement"})
  end,

  on_lose = function (self, player, is_death)
    local room = player.room
      room:setPlayerMark(player, "@@tey__huiqiang1", 0)
      room:setPlayerMark(player, "@@tey__huiqiang2", 0)
      room:setPlayerMark(player, "@@tey__huiqiang3", 0)
      room:setPlayerMark(player, "tey__huiqiang1", 0)
      room:setPlayerMark(player, "tey__huiqiang2", 0)
      room:setPlayerMark(player, "tey__huiqiang3", 0)
      room:setPlayerMark(player, "@$tey__huiqiang", 0)
      player:setSkillUseHistory(self.name, 0, Player.HistoryTurn)
  end,
}

local tey__shisha = fk.CreateTriggerSkill{
  name = "tey__shisha",
  anim_type = "special",
  mute = true,
  frequency = Skill.Compulsory,
  events = {fk.EventPhaseStart},
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(self) and player:hasSkill("tey__huiqiang") and player.phase == Player.Start
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local all_names , names = player:getTableMark("@$tey__huiqiang"), {}
    for i = 1, 3, 1 do
      local card_name = all_names[i]
      all_names[i] = "tey__huiqiang_index:::"..i..":"..card_name
      if Fk:cloneCard(card_name).trueName == "slash" then
        table.insert(names, all_names[i])
      end
    end
    local x = #names
    if x > 0 then
    for _ = 1, x, 1 do
      if player.dead then break end
      local slash = Fk:cloneCard("thunder__slash")
      local max_num = slash.skill:getMaxTargetNum(player, slash)
      local targets = {}
      for _, p in ipairs(room:getOtherPlayers(player)) do
        if not player:isProhibited(p, slash) then
          table.insert(targets, p.id)
        end
      end
      if #targets == 0 or max_num == 0 then return end
      local toos = room:askForChoosePlayers(player, targets, 1, max_num, "#tey__shisha_slash", self.name, false)
      local use = {from = player.id, tos = table.map(toos, function(id) return {id} end), card = slash, extraUse = true}
      if not use then break end
      if use then
        player:broadcastSkillInvoke(self.name, math.random(4))
        use.extraUse = true
        room:useCard(use)
        if not use.damageDealt then
          local all_names , names = player:getTableMark("@$tey__huiqiang"), {}
          for i = 1, 3, 1 do
            local card_name = all_names[i]
            all_names[i] = "tey__huiqiang_index:::"..i..":"..card_name
            if Fk:cloneCard(card_name).trueName == "slash" then
              table.insert(names, all_names[i])
            end
          end
          if #names == 0 then return end
          local result = room:askForChoices(
            player,
            names,
            1,
            1, 
            self.name,
            "#tey__shisha_tranform_blank",
            false
          )
          if #result == 0 then return end
          player:broadcastSkillInvoke(self.name, 5)
          local mark = player:getTableMark("@$tey__huiqiang")
          mark[tonumber(string.split(result[1], ":")[4])] = "jink"
          room:setPlayerMark(player, "@$tey__huiqiang", mark)
        end
      end
    end
    else
    local targets = table.map(room.alive_players, Util.IdMapper)
    local tos = room:askForChoosePlayers(player, targets, 1, 1, "#tey__shisha-choose", self.name, false)
    player:broadcastSkillInvoke(self.name, math.random(6,7))
    local tos1 = room:getPlayerById(tos[1])
    if not tos1.dead then
      tos1:setChainState(not tos1.chained)
    end
    end
  end,
}

Lisa:addSkill(tey__huiqiang)
Lisa:addSkill(tey__shisha)

Fk:loadTranslationTable{
  ["tey__Lisa"] = "丽莎", 
  ["#tey__Lisa"] = "蔷薇魔女",
  ["cv:tey__Lisa"] = "钟可",
  ["illustrator:tey__Lisa"] = "Mihan",
  ["designer:tey__Lisa"] = "幽蝶化烬",

  ["tey__huiqiang"] = "晖蔷",
  [":tey__huiqiang"] = "<a href='transform_skill_href'>转换技</a>，每回合限一次，你使用或被使用非基本牌时，若目标唯一，"..
  "你可以令此牌效果改为①【无中生有】②【洞烛先机】③【增兵减灶】。发动末项后，你将一个非【杀】牌名改为雷【杀】。",
  ["@@tey__huiqiang1"] = "晖蔷 ①",
  ["@@tey__huiqiang2"] = "晖蔷 ②",
  ["@@tey__huiqiang3"] = "晖蔷 ③",
  ["@$tey__huiqiang"] = "晖蔷",
  ["tey__huiqiang_index"] = "[%arg] "..Fk:translate("%arg2"),
  ["#tey__huiqiang_tranform"] = "请确认 晖蔷 覆盖使用牌后的效果，点选当前项并确认后发动。",
  ["#tey__huiqiang_tranform_slash"] = "请确认 晖蔷 替换为【杀】的牌名（【闪】为摸一张牌的效果，不作为牌名计入选项）。",
  ["tey__shisha"] = "逝沙",
  [":tey__shisha"] = "锁定技，准备阶段，若〖晖蔷〗中没有雷【杀】，你横置或重置一名角色，否则每有一个雷【杀】，你便视为使用雷【杀】（无距离限制，若未造成伤害则对应牌名改为“摸一张牌”）。"..
  "<br><font color='grey'>直接修改为空白牌会报错，UI显示为【闪】时，其效果为摸一张牌。",
  ["#tey__shisha_slash"] = "逝沙：请视为使用雷【杀】（无距离限制）。",
  ["#tey__shisha_tranform_blank"] = "请确认 晖蔷 替换为 摸一张牌（显示为【闪】） 的 【杀】牌名。",
  ["#tey__shisha-choose"] = "选择一名角色，改变其连环状态。",

  ["$tey__huiqiang1"] = "真贴心呢，小可爱，姐姐我很满意哦~",
  ["$tey__huiqiang2"] = "任务是做不完的，还不如陪姐姐，聊会儿天？",
  ["$tey__huiqiang3"] = "呵呵，你很擅长做这些呢~",
  ["$tey__huiqiang4"] = "明明是该喝下午茶的时间…",
  ["$tey__shisha1"] = "这是，惩罚哦！",
  ["$tey__shisha2"] = "酥酥麻麻的哦~",
  ["$tey__shisha3"] = "快点投降吧~",
  ["$tey__shisha4"] = "可别上瘾哦~",
  ["$tey__shisha5"] = "哎呀，这可真是…",
  ["$tey__shisha6"] = "该不会想让我加班吧？那可不好哦~",
  ["$tey__shisha7"] = "锻炼的机会，应该多留给新人，不是么？",
  ["~tey__Lisa"] = "果然不该出门的…",
} 

local tey__fenglie = fk.CreateTriggerSkill{
  name = "tey__fenglie",
  anim_type = "offensive",
  events = {fk.EventPhaseStart},
  mute = true,
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(self) and player.phase == Player.Play
  end,
  on_cost = Util.TrueFunc, 
  on_use = function(self, event, target, player, data)
    local room = player.room
    local tos = room:askForChoosePlayers(player, table.map(room.alive_players, Util.IdMapper),
    1, 1, "#tey__fenglie_slash", self.name, true)
    if #tos > 0 then
    local target = room:getPlayerById(tos[1])
    if #table.map(table.filter(room:getOtherPlayers(target), function(p)
      return target:inMyAttackRange(p) end), Util.IdMapper) == 0 then return end
    local _, dat = room:askForUseActiveSkill(target, "tey__fenglie_viewas", "#tey__fenglie-ask", false)
    if dat then
    player:broadcastSkillInvoke(self.name, math.random(2))
    local card = Fk.skills["tey__fenglie_viewas"]:viewAs(dat.cards)
    local use = {
    from = target.id,
    tos = table.map(dat.targets, function(id) return {id} end),
    card = card,
    extraUse = true,}
    room:useCard(use)
    room:setPlayerMark(target, "tey__fenglie-turn", 1)
    local choices = {"tey__fenglie_recast","cancel"}
    local choice = room:askForChoice(player, choices, self.name, "#tey__fenglie-choice")
    if choice == "tey__fenglie_recast" then
    target:showCards(target.player_cards[target.Hand])
    local ids = {}
    for _, id in ipairs(target.player_cards[target.Hand]) do
      if Fk:getCardById(id).color == Card.Red and Fk:getCardById(id).type == Card.TypeBasic then
      table.insert(ids, id)
      end
    end
      if #ids > 0 then
      player:broadcastSkillInvoke(self.name, 3)
      room:recastCard(ids, target, self.name)
      room:setPlayerMark(target, "@tey__fenglie-turn", #ids)
      end
    end
    end
    end
  end,
}
local tey__fenglie_viewas = fk.CreateViewAsSkill{
  name = "tey__fenglie_viewas",
  pattern = "fire__slash",
  card_filter = Util.FalseFunc,
  view_as = function(self, cards)
    local card = Fk:cloneCard("fire__slash")
    card.skillName = "tey__fenglie"
    return card
  end,
}
local tey__fenglie_delay = fk.CreateTriggerSkill{
  name = "#tey__fenglie_delay",
  frequency = Skill.Compulsory,
  anim_type = "masochism",
  events = {fk.Damage, fk.Damaged},
  can_trigger = function(self, event, target, player, data)
    return target:getMark("tey__fenglie-turn") > 0
  end,
  on_use = function (self, event, target, player, data)
    local room = target.room
    target:broadcastSkillInvoke("tey__fenglie", 4)
    local x = target:getMark("@tey__fenglie-turn") + 1
    target:drawCards(x, self.name, nil)
    room:setPlayerMark(target,"tey__fenglie-turn",0)
    room:setPlayerMark(target,"@tey__fenglie-turn",0)
  end,
}
Fk:addSkill(tey__fenglie_viewas)
tey__fenglie:addRelatedSkill(tey__fenglie_delay)
Diluc:addSkill(tey__fenglie)

Fk:loadTranslationTable{
  ["tey__Diluc"] = "迪卢克", 
  ["#tey__Diluc"] = "晨曦的暗面",
  ["cv:tey__Diluc"] = "马洋",
  ["illustrator:tey__Diluc"] = "ngkhyn",
  ["designer:tey__Diluc"] = "幽蝶化烬",

  ["tey__fenglie"] = "烽烈",
  [":tey__fenglie"] = "出牌阶段开始时，你可以令一名角色视为使用火【杀】。结算后，你可以令其展示手牌并重铸其中的红色基本牌，且其本回合下次造成或受到伤害后你摸重铸牌数+1张牌。（未重铸则视为1）",
  ["#tey__fenglie_slash"] = "烽烈：选择视为使用火【杀】的角色",
  ["tey__fenglie_viewas"] = "烽烈",
  ["#tey__fenglie-ask"] = "烽烈：选择使用火【杀】的目标",
  ["@tey__fenglie-turn"] = "烽烈",
  ["#tey__fenglie_delay"] = "烽烈",
  ["tey__fenglie_recast"] = "令其展示手牌并重铸所有红色基本牌",
  ["#tey__fenglie-choice"] = "烽烈 请选择令火【杀】使用者执行的一项：",

  ["$tey__fenglie1"] = "为了达成目标，力量是必须的。",
  ["$tey__fenglie2"] = "我必须前进，不论有谁阻挡在我面前。",
  ["$tey__fenglie3"] = "需要用刀剑以外的方法去斩断…",
  ["$tey__fenglie4"] = "在此————宣判！",
  ["~tey__Diluc"] = "败者…没有借口…",
}

local tey__daiqie = fk.CreateViewAsSkill{
  name = "tey__daiqie",
  pattern = "lure_tiger,await_exhausted",
  anim_type = "control",
  prompt = "tey__daiqie",
  card_filter = Util.FalseFunc,
  interaction = function(self)
    return UI.ComboBox { choices = {"lure_tiger","await_exhausted"} }
  end,
  view_as = function(self, cards)
    local choice = self.interaction.data
    if Self.chained or not choice then return end
    local c = Fk:cloneCard(choice)
    c:addSubcards(cards)
    c.skillName = self.name
    return c
  end,
  before_use = function(self, player, use)
    player:setChainState(true)
  end,
  enabled_at_response = function(self, player, response)
    return not response
  end,
}
local tey__daiqie_trigger = fk.CreateTriggerSkill{
  name = "#tey__daiqie_trigger",
  mute = true,
  events = {fk.DamageCaused, fk.DamageInflicted},
  can_trigger = function(self, event, target, player, data)
    return target == player and data.card and data.card.trueName == "slash" and player:hasSkill(self)
  and player.chained
  end,
  on_use = function(self, event, target, player, data)
    player:broadcastSkillInvoke("tey__daiqie")
    player:setChainState(false)
  end,
}
local tey__yinjue = fk.CreateTriggerSkill{
  name = "tey__yinjue",
  events = {fk.TurnEnd},
  can_trigger = function(self, event, target, player, data)
    return target and player:hasSkill(self) 
    and player:getMark("tey__yinjue-turn") == 0 and not player:prohibitUse(Fk:cloneCard("slash")) 
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local choices = {"tey__yinjue_use"}
    if not player:isKongcheng() then
      table.insert(choices, "tey__yinjue_halfuse")
    end
    local choice = room:askForChoice(player, choices, self.name, "#tey__yinjue-choice:")
    if choice == "tey__yinjue_use" then
      local use = room:askForUseCard(player, "slash", "slash", "#tey__yinjue_use:", true, { bypass_times = true })
      if use then
        use.extraUse = true
        room:useCard(use)
        player:drawCards(1, self.name)
      end
    elseif choice == "tey__yinjue_halfuse" then
      local num = (player:getHandcardNum() - 1) // 2
      local card = room:askForCard(player, math.max(1, num), math.max(1, num), 
      false, self.name, true, ".", "#tey__yinjue_halfuse:")
      if #card > 0 then
        local slash = Fk:cloneCard("ice__slash")
        slash.skillName = self.name
        for _, id in ipairs(card) do
          slash:addSubcard(id)
        end
        if player:canUseTo(slash, target, { bypass_times = true, bypass_distances= true }) then
        room:useCard{
          from = player.id,
          card = slash,
          tos = { { target.id } },
          extraUse = true,
        }
        end
      end
    end
  end,

  refresh_events = {fk.TargetConfirmed},
  can_refresh = function(self, event, target, player, data)
    return target == player and player:hasSkill(self, true) and
    data.card.color == Card.Black and player:getMark("tey__yinjue-turn") == 0
  end,
  on_refresh = function(self, event, target, player, data)
    player.room:addPlayerMark(player, "tey__yinjue-turn")
  end,
}

tey__daiqie:addRelatedSkill(tey__daiqie_trigger)
Rosaria:addSkill(tey__daiqie)
Rosaria:addSkill(tey__yinjue)

Fk:loadTranslationTable{
  ["tey__Rosaria"] = "罗莎莉亚", 
  ["#tey__Rosaria"] = "棘冠恩典",
  ["cv:tey__Rosaria"] = "张安琪",
  ["illustrator:tey__Rosaria"] = "Tatty",
  ["designer:tey__Rosaria"] = "幽蝶化烬",

  ["tey__daiqie"] = "怠憩",
  [":tey__daiqie"] = "你可以横置，视为使用【以逸待劳】或【调虎离山】。你造成或受到【杀】的伤害时，你可以重置。",
  ["tey__yinjue"] = "隐决",
  [":tey__yinjue"] = "每回合结束时，若你本回合未成为过黑色牌的目标，你可以选择一项：使用一张【杀】并摸一张牌；或将半数取下张手牌（小于一则改为一张）当冰【杀】对当前回合角色使用。",
  ["#tey__daiqie_trigger"] = "怠憩",
  ["#tey__yinjue-choice"] = "发动 隐决，请选择一项",
  ["tey__yinjue_use"] = "使用【杀】，摸一张牌",
  ["tey__yinjue_halfuse"] = "将半数手牌当冰【杀】对当前回合角色使用",
  ["#tey__yinjue_use"] = "请选择使用的【杀】",
  ["#tey__yinjue_halfuse"] = "请选择半数手牌",

  ["$tey__daiqie1"] = "什么都可以商量，除了加班。",
  ["$tey__daiqie2"] = "如果只想祈祷，还请找其他修女。",
  ["$tey__yinjue1"] = "审判！",
  ["$tey__yinjue2"] = "制裁！",
  ["~tey__Rosaria"] = "这样也好…",
}

--夏洛蒂【访览】
local tey__fanglan = fk.CreateActiveSkill{
  name = "tey__fanglan",
  anim_type = "drawcard",
  card_num = 0,
  target_num = 1,
  can_use = function(self, player)
    return player:usedSkillTimes(self.name, Player.HistoryPhase) < 2
  end,
  card_filter = function(self, to_select, selected)
    return false
  end,
  target_filter = function(self, to_select, selected, selected_cards)
    return #selected == 0 and to_select ~= Self.id
  end,
  on_use = function(self, room, effect)
    local player = room:getPlayerById(effect.from)
    local target = room:getPlayerById(effect.tos[1])
    local choices = {"tey__fanglan_draw"}
    if not target:isNude() then
      table.insert(choices, "tey__fanglan_give")
    end
    local choice = room:askForChoice(target, choices, self.name, "#tey__fanglan-choice::"..player.id)
    if choice == "tey__fanglan_draw" then
      player:drawCards(1, self.name)
    local victims = table.map(table.filter(room:getAlivePlayers(), function(p)
      return player == p or target == p end), Util.IdMapper)
    local tos = room:askForChoosePlayers(player, victims, 1, 1, "#tey__fanglan-exclu", self.name, false)
    local vict = room:getPlayerById(tos[1])
    local use = U.askForUseRealCard(room, player, player:getCardIds("h"), ".|.|.|.|.|basic,trick|.", self.name,
    "访览：你可以对其使用一张非装备牌，或取消并可以对其使用一张装备牌",
      {exclusive_targets = {vict.id}, bypass_distances = true, bypass_times = true}, true, true)
    if use then
        use.tos = {}
        if not player:isProhibited(vict, use.card) then
          if use.card.skill:modTargetFilter(vict.id, {}, player, card, false) then
          table.insert(use.tos, {vict.id})
          end
        end
        room:useCard(use)
    else
      local card2 = room:askForCard(player, 1, 1, false, self.name, true, ".|.|.|.|.|equip", "访览：你可以对其使用一张装备牌")
      if #card2 > 0 and Fk:getCardById(card2[1], true).skill:modTargetFilter(vict.id, {}, player, Fk:getCardById(card2[1], true), false) 
      and not player:isProhibited(vict, Fk:getCardById(card2[1], true)) then
      room:useCard{
        card = Fk:getCardById(card2[1], true),
        from = player.id,
        tos = { {vict.id} },
        extraUse = true,
      }
      end
    end
    elseif choice == "tey__fanglan_give" then
      local card = room:askForCard(target, 1, 1, true, self.name, false, ".", "#tey__fanglan")
      room:obtainCard(player.id, card[1], false, fk.ReasonGive, target.id)
      U.askForUseRealCard(room, player, card, ".", self.name, nil, {bypass_distances = true, bypass_times = true}, false, false)
      end
  end,
}

--夏洛蒂【撰异】
local tey__zhuanyi = fk.CreateViewAsSkill{
  name = "tey__zhuanyi",
  anim_type = "defensive",
  prompt = "#tey__zhuanyi-viewas",
  pattern = "nullification",
  card_filter = function(self, to_select, selected)
    if #selected ~= 0 then return false end
    local card = Fk:getCardById(to_select)
    return card:getMark("@@tey__zhuanyi-inhand") > 0
  end,
  view_as = function(self, cards)
    if #cards ~= 1 then return nil end
    local c = Fk:cloneCard("nullification")
    c.skillName = self.name
    c:addSubcard(cards[1])
    return c
  end,
  enabled_at_play = function(self, player)
    return #table.filter(player:getCardIds("h"), function (id)
      return Fk:getCardById(id):getMark("@@tey__zhuanyi-inhand") > 0
    end) > 0 
  end,
  enabled_at_response = function(self, player, response)
    return not response and #table.filter(player:getCardIds("h"), function (id)
      return Fk:getCardById(id):getMark("@@tey__zhuanyi-inhand") > 0
    end) > 0 
  end,
}
local tey__zhuanyi_trigger = fk.CreateTriggerSkill{
  name = "#tey__zhuanyi_trigger",
  anim_type = "defensive",
  events = { fk.TargetConfirming },
  can_trigger = function(self, event, target, player, data)
    if not player:hasSkill(self) then return false end
      return target == player and data.card.is_damage_card
      and player:usedSkillTimes(self.name, Player.HistoryRound) == 0 and data.from ~= player.id
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    player:broadcastSkillInvoke("tey__zhuanyi")
      AimGroup:cancelTarget(data, player.id)
      local underhanding = Fk:cloneCard("underhanding")
      underhanding.skillName = self.name
        local use = {from = data.from, tos = { {player.id} }, card = underhanding, extraUse = true}
        room:useCard(use)
      return true
  end,

  refresh_events = {fk.AfterCardsMove},
  can_refresh = function(self, event, target, player, data)
    return player:hasSkill("tey__zhuanyi", true)
  end,
  on_refresh = function(self, event, target, player, data)
    local room = player.room
    for _, move in ipairs(data) do
      if move.to == player.id and move.toArea == Player.Hand and 
      (move.moveReason == fk.ReasonPrey or move.moveReason == fk.ReasonGive) and
       (move.skillName == "underhanding_skill" or move.skillName == "hanqing__underhanding_skill" or move.skillName == "steam__underhanding_skill"
       or move.skillName == "ysch_Al__underhanding_skill") then
        for _, info in ipairs(move.moveInfo) do -- 唉，一服三制
          local id = info.cardId
          if room:getCardArea(id) == Card.PlayerHand and room:getCardOwner(id) == player then
            room:setCardMark(Fk:getCardById(id), "@@tey__zhuanyi-inhand", 1)
          end
        end
      end
    end
  end,
}
local tey__zhuanyi_maxcards = fk.CreateMaxCardsSkill{
  name = "#tey__zhuanyi_maxcards",
  exclude_from = function(self, player, card)
    return card and card:getMark("@@tey__zhuanyi-inhand") ~= 0
  end,
}
tey__zhuanyi:addRelatedSkill(tey__zhuanyi_trigger)
tey__zhuanyi:addRelatedSkill(tey__zhuanyi_maxcards)
Charlotte:addSkill(tey__fanglan)
Charlotte:addSkill(tey__zhuanyi)

Fk:loadTranslationTable{
  ["tey__Charlotte"] = "夏洛蒂", 
  ["#tey__Charlotte"] = "著文鸟闻",
  ["cv:tey__Charlotte"] = "阮从青",
  ["illustrator:tey__Charlotte"] = "Orange Sekaii",
  ["designer:tey__Charlotte"] = "幽蝶化烬",

  ["tey__fanglan"] = "访览",
  [":tey__fanglan"] = "出牌阶段限两次，你可以令一名其他角色选择一项：令你摸一张牌，然后你可以对你或其使用一张牌；或交给你一张牌，然后你可以使用此牌。（均无距离次数限制）",
  ["tey__zhuanyi"] = "撰异",
  [":tey__zhuanyi"] = "你因【瞒天过海】获得的牌不计入手牌上限且可以当【无懈可击】使用。每轮限一次，其他角色对你使用伤害牌时，你可以改为令其视为对你使用【瞒天过海】。",
  ["#tey__fanglan-choice"] = "访览：选择令 %dest 执行的一项",
  ["tey__fanglan_draw"] = "令其摸一张牌",
  ["tey__fanglan_give"] = "交给其一张牌",
  ["#tey__fanglan-exclu"] = "访览：选择要使用牌的角色",
  ["@@tey__zhuanyi-inhand"] = "撰异",
  ["#tey__zhuanyi-viewas"] = "发动 撰异，将一张因【瞒天过海】获得的牌当【无懈可击】使用",
  ["#tey__zhuanyi_trigger"] = "撰异",

  ["$tey__fanglan1"] = "欸！可惜，又没抓拍到闪电…",
  ["$tey__fanglan2"] = "来，听我指挥，先摆一个好看的姿势…",
  ["$tey__zhuanyi1"] = "真实至上，故事超群。这就是我的工作原则！",
  ["$tey__zhuanyi2"] = "谎言处处圆滑，真相棱角分明。",
  ["~tey__Charlotte"] = "标题，还没想…",
}

local tey__fuchong = fk.CreateTriggerSkill{
  name = "tey__fuchong",
  anim_type = "drawcard",
  mute = true,
  events = {fk.RoundStart},
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(self)
  end,
  on_cost = function(self, event, target, player, data)
    return player.room:askForSkillInvoke(player, self.name, nil, "#tey__fuchong-invoke")
  end,
  on_use = function(self, event, target, player, data)
  local choices = {"fuchong_exchange","fuchong_gain"}
  local choice = player.room:askForChoice(player, choices, self.name, "#tey__fuchong-choice")
  player:broadcastSkillInvoke(self.name, math.random(2))
  if choice == "fuchong_exchange" then
    local ids = {}
    player.room.logic:getEventsOfScope(GameEvent.MoveCards, 1, function (e)
    for _, move in ipairs(e.data) do
      if move.toArea == Card.DiscardPile then
        for _, info in ipairs(move.moveInfo) do
          table.insertIfNeed(ids, info.cardId)
        end
      end
    end
    return false
  end, Player.HistoryGame)
  ids = table.filter(ids, function (id) return player.room:getCardArea(id) == Card.DiscardPile
  and Fk:getCardById(id).trueName == "slash" and Fk:getCardById(id).name ~= "slash" end)
  if #ids == 0 then return end
  player.room:moveCards({
    ids = ids,
    toArea = Card.Processing,
    moveReason = fk.ReasonJustMove,
    skillName = self.name,
    proposer = player.id,
  })
    local cardmap = player.room:askForArrangeCards(player, self.name,
    {ids, player:getCardIds(Player.Hand), "slash", "$Hand"}, "#fuchong-exchange" , false)
    local topile = table.filter(cardmap[1], function (id)
      return not table.contains(ids, id)
    end)
    if #topile > 0 then
      player.room:moveCardTo(topile, Card.Processing, nil, fk.ReasonPut, self.name, "", true, player.id)
      topile = table.filter(ids, function (id)
        return not table.contains(cardmap[1], id)
      end)
      if player.dead then
        player.room:moveCardTo(topile, Card.DiscardPile, nil, fk.ReasonJustMove, self.name, "", true)
      else
        player.room:moveCardTo(topile, Card.PlayerHand, player, fk.ReasonJustMove, self.name, "", true, player.id)
      end
    end
    local top = cardmap[1]
    top = table.reverse(top)
    player.room:moveCards({
      ids = top,
      toArea = Card.DiscardPile,
      moveReason = fk.ReasonPut,
      skillName = self.name,
      proposer = player.id,
      moveVisible = true,
    })
  elseif choice == "fuchong_gain" then
    if #player.room.draw_pile > 0 then
      local cards = player.room:getCardsFromPileByRule("slash|.|heart,diamond", 1)
      if #cards > 0 then
        player.room:obtainCard(player, cards[1], false, fk.ReasonJustMove)
      end
    end
    for _, id in ipairs(player:getCardIds("h")) do
      if Fk:getCardById(id):getMark("@@ShownCards-inhand") == 0 then
      player.room:setCardMark(Fk:getCardById(id), "@@ShownCards-inhand", 1)
    end
    end
  end
  end, 
}
local tey__fuchong_delay = fk.CreateTriggerSkill{
  name = "#tey__fuchong_delay",
  anim_type = "control",
  events = {fk.DamageInflicted, fk.EventPhaseStart},
  can_trigger = function(self, event, target, player, data)
    if event == fk.DamageInflicted then
      return target == player and player:hasSkill(self)
    elseif event == fk.EventPhaseStart then
      return target == player and player:hasSkill(self) and player.phase == Player.Judge
    end
  end,
  on_cost = function (self, event, target, player, data)
    if #table.filter(player.player_cards[Player.Hand], function(id) 
      return (Fk:getCardById(id):getMark("@@ShownCards-inhand") == 0 and Fk:getCardById(id).trueName == "slash") end) >= 2 then
    return player.room:askForSkillInvoke(player, self.name, nil, "#tey__fuchong_delay-invoke")
      end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local choices = {}
    if #table.filter(player.player_cards[Player.Hand], function(id) 
      return (Fk:getCardById(id):getMark("@@ShownCards-inhand") == 0 and Fk:getCardById(id).trueName == "slash") end) >= 2 then
      local success, dat = player.room:askForUseActiveSkill(player, "tey__fuchong_active", "#tey__fuchong_active", false)
      if success and dat then
      for _, id in ipairs(dat.cards) do
        room:setCardMark(Fk:getCardById(id, true), "@@ShownCards-inhand", 1)
      end
     end
  end
  player:broadcastSkillInvoke("tey__fuchong", math.random(3,4))
    return true
  end,
}
local tey__fuchong_active = fk.CreateActiveSkill{
  name = "tey__fuchong_active",
  min_card_num = 2,
  max_card_num = 2,
  target_num = 0,
  card_filter = function(self, to_select, selected)
    return #selected < 2 and Fk:currentRoom():getCardArea(to_select) == Card.PlayerHand
    and Fk:getCardById(to_select).trueName == "slash" and Fk:getCardById(to_select):getMark("@@ShownCards-inhand") == 0
  end,
}

local tey__jixie = fk.CreateTriggerSkill{
  name = "tey__jixie",
  anim_type = "offensive",
  frequency = Skill.Compulsory,
  events = {fk.PreCardUse},
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(self) and #table.filter(player.player_cards[Player.Hand], function(id)
      return Fk:getCardById(id):getMark("@@ShownCards-inhand") == 0 end) == 1 and data.card:getMark("@@ShownCards-inhand") == 0
      and not (data.card:isVirtual() and #data.card.subcards ~= 1) and #table.filter(player.player_cards[Player.Hand], function(id)
        return Fk:getCardById(id):getMark("@@ShownCards-inhand") > 0 end) > 0 
  end,
  on_use = function(self, event, target, player, data)
    data.disresponsiveList = table.map(player.room.alive_players, Util.IdMapper)
    if data.card.name == "thunder__slash" or data.card.name == "fire__slash" then
      data.additionalDamage = (data.additionalDamage or 0) + 1
    end
  end,
}
local tey__jixie_targetmod = fk.CreateTargetModSkill{
  name = "#tey__jixie_targetmod",
  anim_type = "offensive",
  bypass_distances = function (self, player, skill, card)
    return player:hasSkill("tey__jixie") and card:getMark("@@ShownCards-inhand") > 0
    and table.find(player.player_cards[Player.Hand], function(id)
      return Fk:getCardById(id):getMark("@@ShownCards-inhand") == 0 end)
  end
}

Fk:addSkill(tey__fuchong_active)
tey__fuchong:addRelatedSkill(tey__fuchong_delay)
tey__jixie:addRelatedSkill(tey__jixie_targetmod)
Chevreuse:addSkill(tey__fuchong)
Chevreuse:addSkill(tey__jixie)

Fk:loadTranslationTable{
  ["tey__Chevreuse"] = "夏沃蕾", 
  ["#tey__Chevreuse"] = "明律决罚",
  ["cv:tey__Chevreuse"] = "潘丹妮",
  ["illustrator:tey__Chevreuse"] = "一条坠子",
  ["designer:tey__Chevreuse"] = "幽蝶化烬",

  ["tey__fuchong"] = "伏铳",
  [":tey__fuchong"] = "每轮开始时，你可以选择一项：将任意张手牌替换为弃牌堆等量张属性【杀】；或获得牌堆一张随机的红色【杀】并明置所有手牌。"..
  "你受到伤害时或判定阶段，你可以改为明置两张【杀】。",
  ["#tey__fuchong-invoke"] = "发动伏铳 请选择一项执行",
  ["#tey__fuchong-choice"] = "发动伏铳 请选择一项执行",
  ["fuchong_exchange"] = "将任意张手牌替换为弃牌堆等量张属性【杀】",
  ["fuchong_gain"] = "获得牌堆一张随机的红色【杀】并明置所有手牌",
  ["#fuchong-exchange"] = "请将手牌与弃牌堆中的属性【杀】交换",
  ["#tey__fuchong_delay"] = "伏铳",
  ["#tey__fuchong_delay-invoke"] = "是否发动 伏铳，明置两张杀代替受到的伤害或判定阶段。 ",
  ["tey__fuchong_active"] = "伏铳",
  ["#tey__fuchong_active"] = "伏铳 请选择两张【杀】明置",
  ["tey__jixie"] = "击懈",
  [":tey__jixie"] = "锁定技，若你手牌中有暗置牌，你使用明置牌无距离限制；若你手牌中有明置牌，你使用唯一暗置手牌不可响应，若为火【杀】或雷【杀】则伤害+1。",

  ["$tey__fuchong1"] = "等等，我要维护一下铳枪。以免它的机关结构被冻住。",
  ["$tey__fuchong2"] = "不错。端枪的手更稳了。",
  ["$tey__fuchong3"] = "不许动!",
  ["$tey__fuchong4"] = "放下武器!",
  ["$tey__jixie1"] = "有些罪犯会用雷鸣声来掩盖枪声，但这骗不过我的耳朵。",
  ["$tey__jixie2"] = "这样的话，也许能狙击到更远的敌人…",
  ["~tey__Chevreuse"] = "正义…何在…",
}

--克洛琳德【执决】
local tey__zhijue = fk.CreateTriggerSkill{
  name = "tey__zhijue",
  anim_type = "offensive",
  events = {fk.TargetSpecifying},
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(self) and player:usedSkillTimes(self.name) == 0
    and data.card.is_damage_card and data.firstTarget
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
    local targets = AimGroup:getAllTargets(data.tos)
    local targetis = U.getUseExtraTargets(player.room, data, true, true)
    local choices = {"cancel"}
    if #targets > 0 then table.insert(choices, "zhijue_minus") end
    if #targetis > 0 then table.insert(choices, "zhijue_add") end
    if #choices < 1 then return false end
    local choice = room:askForChoice(player, choices, self.name, "#tey__zhijue-choice::"..player.id,false,{"cancel","zhijue_minus", "zhijue_add"})
      if choice == "zhijue_add" then
        local tos = room:askForChoosePlayers(player, U.getUseExtraTargets(room, data, true), 1, 2,
        "#tey__zhijue-choosemore", self.name, true)
        if #tos > 0 then
        self.cost_data = tos
        return true
      end
    elseif choice == "zhijue_minus" then
        local tos = room:askForChoosePlayers(player, targets, 1, 2, "#tey__zhijue-chooseless", self.name, true)
      if #tos > 0 then
        self.cost_data = tos
        return true
      end
    elseif choice == "cancel" then
      return false
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local tos = table.simpleClone(self.cost_data)
    room:sortPlayersByAction(tos)
    local targets = AimGroup:getAllTargets(data.tos)
    local to
    tos = table.map(tos, function (pid)
      if table.contains(targets, pid) then
        AimGroup:cancelTarget(data, pid)
      else
        AimGroup:addTargets(room, data, pid)
      end
      to = room:getPlayerById(pid)
      return to
    end)
    for _, p in ipairs(tos) do
      local choices1 = {"zhijue_thunder","zhijue_duel"}
      local choice1 = room:askForChoice(p, choices1, self.name, "#tey__zhijue1-choice::"..p.id)
      if choice1 == "zhijue_duel" then
        local duel = Fk:cloneCard("duel")
        duel.skillName = self.name
        local use = {from = p.id, tos = { {player.id} }, card = duel, extraUse = true}
        room:useCard(use)
        if not (use.damageDealt and use.damageDealt[p.id]) then
          table.insertIfNeed(data.nullifiedTargets, p.id)
          end
      elseif choice1 == "zhijue_thunder" then
        local judge = {
          who = p,
          reason = "lightning",
          pattern = ".|2~9|spade",
        }
        room:judge(judge)
        if judge.card.suit == Card.Spade and judge.card.number > 1 and judge.card.number < 10 then
          room:damage{
            to = p,
            damage = 3,
            damageType = fk.ThunderDamage,
            skillName = self.name,
          }
        else
          table.insertIfNeed(data.nullifiedTargets, p.id)
        end
      end
    end
  end,
}

--克洛琳德【慕曦】
local tey__muxi = fk.CreateViewAsSkill{
  name = "tey__muxi",
  anim_type = "switch",
  pattern = "slash,unexpectation",
  switch_skill_name = "tey__muxi",
  expand_pile = function() return U.getMark(Self, "tey__muxi") end,
  prompt = function(self)
    return "#tey__muxi-"..Self:getSwitchSkillState(self.name, false, true)
  end,
  card_filter = function(self, to_select, selected)
    return #selected == 0 and table.contains(U.getMark(Self, "tey__muxi"), to_select)
  end,
  view_as = function(self, cards)
    if #cards ~= 1 then return end
    local card
    if Self:getSwitchSkillState(self.name, false) == fk.SwitchYang then
      card = Fk:cloneCard("slash")
    elseif Self:getSwitchSkillState(self.name, false) == fk.SwitchYin then
      card = Fk:cloneCard("unexpectation")
    end
    card.skillName = self.name
    card:addSubcard(cards[1])
    return card
    end,
  before_use = function(self, player, use)
    if player:getMark("tey__muxi_minus-round") > 0 then
    use.extraUse = true
    end
  end,
  enabled_at_response = function(self, player, response)
    local pat = Fk.currentResponsePattern
    if response and pat and Exppattern:Parse(pat):matchExp("slash")then
      return player:getSwitchSkillState(self.name, false) == fk.SwitchYang
    elseif response and pat and Exppattern:Parse(pat):matchExp("unexpectation")then
      return player:getSwitchSkillState(self.name, false) == fk.SwitchYin
      end
  end,
}
local tey__muxi_trigger = fk.CreateTriggerSkill{
  name = "#tey__muxi_trigger",
  mute = true,
  refresh_events = {fk.AfterCardsMove, fk.EventAcquireSkill},
  can_refresh = function(self, event, target, player, data)
    if player:hasSkill(self, true) then
      if event == fk.AfterCardsMove then
        for _, move in ipairs(data) do
          if move.toArea == Card.DiscardPile then
            for _, info in ipairs(move.moveInfo) do
              if player.room:getCardArea(info.cardId) == Card.DiscardPile then
                return true
              end
            end
          end
          for _, info in ipairs(move.moveInfo) do
            if info.fromArea == Card.DiscardPile and player.room:getCardArea(info.cardId) ~= Card.DiscardPile then
              return true
            end
          end
        end
      else
        return data == self and player == target
      end
    end
  end,
  on_refresh = function(self, event, target, player, data)
    local room = player.room
    if event == fk.AfterCardsMove then
      local ids = U.getMark(player, "tey__muxi")
      for _, move in ipairs(data) do
        if move.toArea == Card.DiscardPile then
          for _, info in ipairs(move.moveInfo) do
            if room:getCardArea(info.cardId) == Card.DiscardPile and
            (move.moveReason == fk.ReasonResonpse
            or move.moveReason == fk.ReasonJudge) then
              table.insertIfNeed(ids, info.cardId)
            end
          end
        end
        for _, info in ipairs(move.moveInfo) do
          if info.fromArea == Card.DiscardPile and room:getCardArea(info.cardId) ~= Card.DiscardPile then
            table.removeOne(ids, info.cardId)
          end
        end
      end
      room:setPlayerMark(player, "tey__muxi", ids)
    else
      local ids = {}
      room.logic:getEventsOfScope(GameEvent.MoveCards, 999, function(e)
        for _, move in ipairs(e.data) do
          if move.toArea == Card.DiscardPile then
            for _, info in ipairs(move.moveInfo) do
              if room:getCardArea(info.cardId) == Card.DiscardPile and
               (move.moveReason == fk.ReasonResonpse
              or move.moveReason == fk.ReasonJudge) then
                table.insertIfNeed(ids, info.cardId)
              end
            end
          end
        end
        return false
      end, Player.HistoryGame)
      room:setPlayerMark(player, "tey__muxi", ids)
    end
  end,
}
local tey__muxi_bypass = fk.CreateTriggerSkill{
  name = "#tey__muxi_bypass",
  mute = true,
  frequency = Skill.Compulsory,
  events = {fk.RoundStart, fk.Damaged, fk.EventAcquireSkill},
  can_trigger = function(self, event, target, player, data)
    if not player:hasSkill(self) then return false end
    if event == fk.RoundStart then
        return player:getMark("tey__muxi_minus-round") == 0
    elseif event == fk.Damaged then
        return target == player and player:hasSkill(self) and player:getMark("tey__muxi_minus-round") > 0
      elseif event == fk.EventAcquireSkill then
        local room = player.room
       return #room.logic:getEventsOfScope(GameEvent.ChangeHp, 1, function(e)
          local damage = e.data[5]
          if damage and damage.to == player then
            return true
          end
        end, Player.HistoryRound) == 0
    end
  end,
  on_use = function(self, event, target, player, data)
    if event == fk.RoundStart or event == fk.EventAcquireSkill then
      local room = player.room
      room:setPlayerMark(player, "tey__muxi_minus-round", 1)
    elseif event == fk.Damaged then
      local room = player.room
      room:setPlayerMark(player, "tey__muxi_minus-round", 0)
      end
  end,
}
local tey__muxi_targetmod = fk.CreateTargetModSkill{
  name = "#tey__muxi_targetmod",
  bypass_times = function(self, player, skill, scope, card)
    if player:getMark("tey__muxi_minus-round") > 0 then
    return card and scope == Player.HistoryPhase and table.contains(card.skillNames, tey__muxi.name)
    end
  end,
}

Clorinde:addSkill(tey__zhijue)
tey__muxi:addRelatedSkill(tey__muxi_trigger)
tey__muxi:addRelatedSkill(tey__muxi_bypass)
tey__muxi:addRelatedSkill(tey__muxi_targetmod)
Clorinde:addSkill(tey__muxi)

Fk:loadTranslationTable{
  ["tey__Clorinde"] = "克洛琳德", 
  ["#tey__Clorinde"] = "秉烛狝影",
  ["cv:tey__Clorinde"] = "赵涵雨",
  ["illustrator:tey__Clorinde"] = "yutik",
  ["designer:tey__Clorinde"] = "幽蝶化烬",

  ["tey__zhijue"] = "执决",
  [":tey__zhijue"] = "每回合限一次，你使用伤害牌指定首个目标时，可以多或少指定一至两名目标，令其各选择一项：执行【闪电】判定；或视为对你使用【决斗】。若其未因此受到伤害，此牌对其无效。",
  ["zhijue_add"] = "增加一至两名目标",
  ["zhijue_minus"] = "减少一至两名目标",
  ["zhijue_thunder"] = "进行【闪电】判定",
  ["zhijue_duel"] = "视为对使用者使用【决斗】",
  ["#tey__zhijue-choice"] = "是否发动 执决 增加或减少仅两名目标（无距离限制）",
  ["#tey__zhijue-choosemore"] = "发动 执决 增加一至两名目标",
  ["#tey__zhijue-chooseless"] = "发动 执决 减少一至两名目标",
  ["#tey__zhijue1-choice"] = "发动 执决 判定闪电或决斗使用者，未因此受到伤害则使用牌对你无效",
  ["tey__muxi"] = "慕曦",
  [":tey__muxi"] = "转换技，你可以将因判定或打出而进入弃牌堆的牌当 阳：【杀】阴：【出其不意】 使用或打出。若你本轮未受到过伤害，则无次数限制。",
  ["#tey__muxi_bypass"] = "慕曦",
  ["#tey__muxi-yang"] = "发动 慕曦，请将被判定或打出的牌当（当前分支 阳：【杀】）使用或打出",
  ["#tey__muxi-yin"] = "发动 慕曦，请将被判定或打出的牌当（当前分支 阴：【出其不意】）使用或打出",

  ["$tey__zhijue1"] = "握紧长剑之时，我代表的是枫丹的律法与规则。",
  ["$tey__zhijue2"] = "踏上决斗场的人已经无路可逃，用不着再做驱赶。",
  ["$tey__muxi1"] = "剑锋，直指暗影。",
  ["$tey__muxi2"] = "洞见恶孽，逐灭鬼影！",
  ["~tey__Clorinde"] = "胜负…已分…",
  
}
--诺艾尔【馨往】
local tey__xinwang = fk.CreateTriggerSkill{
  name = "tey__xinwang",
  anim_type = "support",
  events = {fk.EventPhaseStart},
  can_trigger = function(self, event, target, player, data)
    local room = player.room
    local victims = table.filter(room.alive_players, function(p) return
      #room.logic:getEventsOfScope(GameEvent.ChangeHp, 1, function(e)
        local damage = e.data[5]
        if damage and damage.to == p then
          return true
        end
      end, Player.HistoryTurn) == 0 and target:inMyAttackRange(p) and p ~= target end)
    return player:hasSkill(self) and target.phase == Player.Finish and #victims > 0
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local choices = {"tey__xinwang_draw", "tey__xinwang_use"}
    local choice = room:askForChoice(player, choices, self.name, "#tey__xinwang-choice::"..player.id)
    if choice == "tey__xinwang_draw" then
      local choicess = {"hp"}
    if player.shield > 0 then
      table.insert(choicess, "shield")
    end
      local choicesd = room:askForChoice(player, choicess, self.name, "#tey__xinwang-card")
      if choicesd == "hp" then
        room:loseHp(player, 1, self.name)
        if not player.dead then
        player:drawCards(2, self.name)
        end
      elseif choicesd == "shield" then
        room:changeShield(player, -1)
        player:drawCards(2, self.name)
    end
  elseif choice == "tey__xinwang_use" then
    local victims = table.filter(room.alive_players, function(p) return
      #room.logic:getEventsOfScope(GameEvent.ChangeHp, 1, function(e)
        local damage = e.data[5]
        if damage and damage.to == p  then
          return true
        end
      end, Player.HistoryTurn) == 0 and target:inMyAttackRange(p) and p ~= target end)
      local tos = room:askForChoosePlayers(player, table.map(victims, Util.IdMapper),
      1, 1, "#tey__xinwang_use", self.name, false)
      local c = room:getPlayerById(tos[1])
      local choices1 = {"tey__xinwang_use_nonEquip", "tey__xinwang_use_Equip"}
      local choice1 = room:askForChoice(player, choices1, self.name, "#tey__xinwang-choiceto::"..c.id)
      if choice1 == "tey__xinwang_use_nonEquip" then
      local use = U.askForPlayCard(room, player, player:getCardIds("h"), ".|.|.|.|.|basic,trick|.", self.name,
      "#tey__xinwang_use", {bypass_times = true , bypass_distances = true , exclusive_targets = {c.id} }, true)
      if use then
        if use.card.type ~= Card.TypeEquip then
          use.tos = {}
            if not player:isProhibited(c, use.card) then
              if use.card.skill:modTargetFilter(c.id, {}, player, card, false) then
                table.insert(use.tos, {c.id})
              end
            end
          if player.shield == 0 then
          use.disresponsiveList = table.map(room.alive_players, Util.IdMapper)
          end
          room:useCard(use)
        end
      end
    elseif choice1 == "tey__xinwang_use_Equip" then
      local card2 = room:askForCard(player, 1, 1, false, self.name, true, ".|.|.|.|.|equip", "#tey__xinwang_use")
      if #card2 > 0 and Fk:getCardById(card2[1], true).skill:modTargetFilter(c.id, {}, player.id, Fk:getCardById(card2[1], true), false) 
      and not player:isProhibited(c, Fk:getCardById(card2[1], true)) then
      room:useCard{
        card = Fk:getCardById(card2[1], true),
        from = player.id,
        tos = { {c.id} },
        extraUse = true,
      }
    end
    end
    end
  end,
}

--诺艾尔【昊力】
local tey__haoli = fk.CreateTriggerSkill{
  name = "tey__haoli",
  anim_type = "support",
  events = {fk.Damage},
  can_trigger = function(self, event, target, player, data)
    if player:hasSkill(self) and target == player then
      local dat = U.getActualDamageEvents(player.room, 1, function(e) return e.data[1].from == target end)
      return #dat > 0 and dat[1].data[1] == data
    end
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
    local mark = player:getTableMark("tey__haoli-round")
    local targets = table.map(table.filter(room.alive_players, function (p)
      return p:isWounded() and not table.contains(mark, p.id)
    end), Util.IdMapper)
      if player.shield > 0 and #targets > 0 then
        return room:askForSkillInvoke(player, self.name, nil, "#tey__haoli")
  elseif player.shield <= 0 then
        return room:loseHp(player, 1, self.name)
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local mark = player:getTableMark("tey__haoli-round")
    if player.shield > 0 then
      local targets = table.map(table.filter(room.alive_players, function (p)
        return p:isWounded() and not table.contains(mark, p.id)
      end), Util.IdMapper)
      if #targets > 0 then
        targets = room:askForChoosePlayers(player, targets, 1, 1, "#tey__haoli-recover", self.name, false)
        if #targets > 0 then
        local tar = room:getPlayerById(targets[1])
        table.insertIfNeed(mark, targets[1])
        room:setPlayerMark(player, "tey__haoli-round", #mark > 0 and mark or 0)
        room:recover({
          who = tar,
          num = 1,
          recoverBy = player,
          skillName = self.name,
        })
        if not tar.dead then
          tar:drawCards(1, self.name)
        end
      end
      end
  elseif player.shield <= 0 then
    if not player.dead then
    room:changeShield(player, 1)
    end
  end
  end,
}

Noelle:addSkill(tey__xinwang)
Noelle:addSkill(tey__haoli)

Fk:loadTranslationTable{
  ["tey__Noelle"] = "诺艾尔", 
  ["#tey__Noelle"] = "未受勋之花",
  ["cv:tey__Noelle"] = "宴宁",
  ["illustrator:tey__Noelle"] = "Naycot",
  ["designer:tey__Noelle"] = "幽蝶化烬",

  ["tey__xinwang"] = "馨往",
  [":tey__xinwang"] = "一名角色结束阶段，若其攻击范围内有角色本回合未受到过伤害，你可以选择一项："..
  "失去1点护甲或体力，摸两张牌；或对其中一名角色使用一张牌（若你没有护甲，此牌不可响应）。",
  ["tey__haoli"] = "昊力",
  [":tey__haoli"] = "你每回合首次造成伤害后，若你有护甲，你可以令一名角色回复1点体力并摸一张牌（每轮每名角色限一次），否则你失去1点体力并获得1点护甲。",
  ["tey__xinwang_draw"] = "摸两张牌",
  ["tey__xinwang_use"] = "使用一张牌",
  ["#tey__xinwang-choice"] = "馨往：选择令 %dest 执行的一项",
  ["#tey__xinwang-card"] = "发动 馨往，请选择一项，然后摸两张牌",
  ["hp"] = "失去体力",
  ["shield"] = "减少护甲",
  ["tey__xinwang_use_nonEquip"] = "使用非装备牌",
  ["tey__xinwang_use_Equip"] = "使用装备牌",
  ["#tey__xinwang-choiceto"] = "馨往：选择对 %dest 使用的牌",
  ["#tey__xinwang_use"] = "请选择一名角色/使用一张牌，目标为此前你选择的唯一角色（确认使用后目标会修正为其）",
  ["#tey__haoli"] = "是否发动 昊力，令一名已受伤角色回复1点体力",
  ["#tey__haoli-recover"] = "发动 昊力，请令一名已受伤角色回复1点体力",

  ["$tey__xinwang1"] = "交给我吧！什么都可以交给我！",
  ["$tey__xinwang2"] = "厨师、园丁、战士、向导…你需要我是什么，我就是什么！",
  ["$tey__haoli1"] = "我会注意骑士的风度。",
  ["$tey__haoli2"] = "我会注意女仆的礼仪。",
  ["~tey__Noelle"] = "让骑士团…蒙羞了…",
}
--卡齐娜【峭峙】
local tey__qiaozhi = fk.CreateActiveSkill{
  name = "tey__qiaozhi",
  anim_type = "drawcard",
  card_num = 0,
  target_num = 0,
  can_use = function(self, player)
    if player:usedSkillTimes(self.name, Player.HistoryPhase) < 1 then
      if (player:getMark("_qiaozhi_1-phase") == player:getMark("_qiaozhi_2-phase") 
      and player:getMark("_qiaozhi_2-phase") == player:getMark("_qiaozhi_3-phase"))
      or (player:getMark("_qiaozhi_1-phase") == 3 and player:getMark("_qiaozhi_2-phase") == 0 and player:getMark("_qiaozhi_3-phase") == 0)
      or (player:getMark("_qiaozhi_1-phase") == 0 and player:getMark("_qiaozhi_2-phase") == 3 and player:getMark("_qiaozhi_3-phase") == 0)
      or (player:getMark("_qiaozhi_1-phase") == 0 and player:getMark("_qiaozhi_2-phase") == 0 and player:getMark("_qiaozhi_3-phase") == 3)
       then return true end
    end
  end,
  card_filter = function(self, to_select, selected)
    return false
  end,
  on_use = function(self, room, effect)
    local player = room:getPlayerById(effect.from)
    local x = player:getAttackRange()
    local y = player.room:getTag("RoundCount")
    local choice = room:askForChoice(player, {"tey__qiaozhi_round", "tey__qiaozhi_range"}, self.name)
    if choice == "tey__qiaozhi_round" then
      if y >= 5 then
        player:drawCards(5, self.name)
        room:setPlayerMark(player, "@tey__qiaozhi-phase", x)
      else
        player:drawCards(y, self.name)
        room:setPlayerMark(player, "@tey__qiaozhi-phase", x)
      end
    elseif choice == "tey__qiaozhi_range" then
      if x >= 5 then
        player:drawCards(5, self.name)
        room:setPlayerMark(player, "@tey__qiaozhi-phase", y)
      else
        player:drawCards(x, self.name)
        room:setPlayerMark(player, "@tey__qiaozhi-phase", y)
      end
      end
  end,
}

local tey__qiaozhi1 = fk.CreateTriggerSkill{
  name = "#tey__qiaozhi1",
  anim_type = "damage",
  events = {fk.EventPhaseEnd},
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(self) and player.phase == Player.Play and
    player:getAttackRange() == player.room:getTag("RoundCount")
  end,
  on_cost = function(self, event, target, player, data)
    local to = player.room:askForChoosePlayers(player, table.map(player.room.alive_players, Util.IdMapper),
    1, 1, "#qiaozhi1-choose", self.name, true, true)
    if #to > 0 then
      self.cost_data = to[1]
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local to = room:getPlayerById(self.cost_data)
    room:damage{
      from = player,
      to = to,
      damage = 1,
      skillName = self.name,
    }
  end,
}

local qiaozhi_strike = fk.CreateTriggerSkill{
  name = "#qiaozhi_strike",
  mute = true,
  frequency = Skill.Compulsory,
  events = {fk.TargetSpecified},
  can_trigger = function(self, event, target, player, data)
    return target == player and player.phase == Player.Play and player:hasSkill("tey__qiaozhi") 
    and data.card.type ~=Card.TypeEquip and player:getMark("@tey__qiaozhi-phase") > 0
  end,
  on_use = function(self, event, target, player, data)
    data.disresponsive = true
  end,
  
  refresh_events = {fk.CardUseFinished},
  can_refresh = function(self, event, target, player, data)
    return target == player and player:hasSkill("tey__qiaozhi", true) and player.phase == Player.Play
  end,
  on_refresh = function(self, event, target, player, data)
  player.room:removePlayerMark(player, "@tey__qiaozhi-phase", 1)
  end,
}
local qiaozhi_stop = fk.CreateProhibitSkill{
  name = "#qiaozhi_stop",
  prohibit_use = function(self, player)
    return player.phase == Player.Play and
     player:getMark("@tey__qiaozhi-phase") <= 0 and player:usedSkillTimes("tey__qiaozhi", Player.HistoryPhase) >= 1
  end,
}
local qiaozhi_record = fk.CreateTriggerSkill{
  name = "#qiaozhi_record",
  refresh_events = {fk.AfterCardUseDeclared},
  can_refresh = function(self, event, target, player, data)
    return target == player and player:hasSkill(tey__qiaozhi) and player.phase == Player.Play
  end,
  on_refresh = function(self, event, target, player, data)
    local room = player.room
    room:addPlayerMark(player, "_qiaozhi_" .. data.card.type .. "-phase")
    room:setPlayerMark(player, "@qiaozhi-phase", string.format("%s-%s-%s",
      player:getMark("_qiaozhi_1-phase"),
      player:getMark("_qiaozhi_2-phase"),
      player:getMark("_qiaozhi_3-phase")))
  end,
}

tey__qiaozhi:addRelatedSkill(tey__qiaozhi1)
tey__qiaozhi:addRelatedSkill(qiaozhi_strike)
tey__qiaozhi:addRelatedSkill(qiaozhi_stop)
tey__qiaozhi:addRelatedSkill(qiaozhi_record)
Kachina:addSkill(tey__qiaozhi)

Fk:loadTranslationTable{
  ["tey__Kachina"] = "卡齐娜", 
  ["#tey__Kachina"] = "斑金矿朴",
  ["cv:tey__Kachina"] = "静宸",
  ["illustrator:tey__Kachina"] = "怪三木",
  ["designer:tey__Kachina"] = "幽蝶化烬",

  ["tey__qiaozhi"] = "峭峙",
  [":tey__qiaozhi"] = "出牌阶段限一次，若你本阶段：使用每类别的牌数均相等；或仅使用三张同类型牌，你可以摸本局轮数或攻击范围张牌（至多摸五张），"..
  "令你本阶段只能再使用等于此时另一项数量的牌且不可响应。<br>出牌阶段结束时，若本局轮数与你攻击范围相等，你可以对一名角色造成1点伤害。",
  ["tey__qiaozhi_round"] = "摸本局轮数张牌",
  ["tey__qiaozhi_range"] = "摸攻击范围张牌",
  ["@tey__qiaozhi-phase"] = "峭峙可用",
  ["#qiaozhi_stop"] = "峭峙",
  ["#qiaozhi_strike"] = "峭峙",
  ["#qiaozhi_record"] = "峭峙",
  ["#tey__qiaozhi1"] = "峭峙",
  ["@qiaozhi-phase"] = "峭峙",
  ["#qiaozhi1-choose"] = "发动 峭峙，请对一名角色造成1点伤害",

  ["$tey__qiaozhi1"] = "冲天转转，出发！",
  ["$tey__qiaozhi2"] = "我可以、我不行、我可以、我…",
  ["~tey__Kachina"] = "不能愧对…「乌沙博蒂」…",
} 

local tey__chipo = fk.CreateTriggerSkill{
  name = "tey__chipo",
  frequency = Skill.Compulsory,
  events = {fk.AfterCardsMove, fk.HpChanged},
  can_trigger = function(self, event, target, player, data)
  if player:hasSkill(self) then
    if event == fk.AfterCardsMove then
      for _, move in ipairs(data) do
        if move.from == player.id and move.moveReason ~= fk.ReasonUse and 
        (move.to ~= player.id or (move.toArea ~= Card.PlayerHand and move.toArea ~= Card.PlayerEquip)) then
          for _, info in ipairs(move.moveInfo) do
            if (info.fromArea == Card.PlayerHand or info.fromArea == Card.PlayerEquip) and
            Fk:getCardById(info.cardId, true).trueName == "slash" then
              return true
            end
          end
        end
      end
  elseif event == fk.HpChanged then
      return target == player
    end
  end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local available = {}
    for _, general in ipairs(room.general_pile) do
      local skills = Fk.generals[general]:getSkillNameList()
      for _, skill_name in ipairs(skills) do
        local skill = Fk.skills[skill_name]
          if
            not skill.lordSkill 
            and not skill.isHiddenSkill 
            and not skill.CenterArea 
            and #skill.attachedKingdom == 0 
            and string.find(Fk:translate(":" .. skill.name, "zh_CN"), "获得")
            and string.find(Fk:translate(":" .. skill.name, "zh_CN"), "【杀】")
            and Fk:translate(skill.name, "zh_CN"):len() == 2
            and skill.name ~= "tea_lianhe" --黑名单一号，bug
          then
          table.insert(available, skill_name)
        end
      end
    end
    local cards1 = table.filter(room.draw_pile, function (id)
      return string.find(Fk:translate(":" .. Fk:getCardById(id).name, "zh_CN"), "【杀】") ~= nil
    end)
    local cards2 = table.filter(room.discard_pile, function (id)
      return string.find(Fk:translate(":" .. Fk:getCardById(id).name, "zh_CN"), "【杀】") ~= nil
    end)
    if #available == 0 then 
      if #cards1 > 0 then
        room:moveCardTo(table.random(cards1), Card.PlayerHand, player, fk.ReasonJustMove, self.name, nil, false, player.id)
      elseif #cards2 > 0 then
        room:moveCardTo(table.random(cards2), Card.PlayerHand, player, fk.ReasonJustMove, self.name, nil, false, player.id)
      elseif #cards1 == 0 and #cards2 == 0 then
        return false
      end
    else
      local get = table.random(available, 1)
      if not table.contains(player:getTableMark("@[:]tey__chipo"), get[1]) then
        room:handleAddLoseSkills(player, get, nil, true, false)
        room:addTableMark(player, "@[:]tey__chipo", get[1])
        local skillslimit = table.map(table.filter(player.player_skills, function (s)
          return s:isPlayerSkill(player) and s.visible and table.contains(player:getTableMark("@[:]tey__chipo"), s.name)
        end), Util.NameMapper)
        if #skillslimit > 2 then
          local tolose = {}
          local x = #skillslimit - 2
          tolose = room:askForChoices(player, skillslimit, x, x, self.name, "#tey__chipo-lose:::"..x, false)
          if #tolose > 0 then
          room:handleAddLoseSkills(player, "-"..table.concat(tolose, "|-"))
          end
        end
      else
        local cards = table.filter(room.draw_pile, function (id)
          return string.find(Fk:translate(":" .. Fk:getCardById(id).name, "zh_CN"), "【杀】") ~= nil
        end)
        if #cards1 > 0 then
          room:moveCardTo(table.random(cards1), Card.PlayerHand, player, fk.ReasonJustMove, self.name, nil, false, player.id)
        elseif #cards2 > 0 then
          room:moveCardTo(table.random(cards2), Card.PlayerHand, player, fk.ReasonJustMove, self.name, nil, false, player.id)
        elseif #cards1 == 0 and #cards2 == 0 then
          return false
        end
      end
    end
  end,

  refresh_events = {fk.AfterSkillEffect},
  can_refresh = function(self, _, target, player, data)
    return target == player and player:hasSkill(data, true) and table.contains(player:getTableMark("@[:]tey__chipo"), data.name)
  end,
  on_refresh = function(self, _, target, player, data)
    local room = player.room
    room:handleAddLoseSkills(player, "-"..data.name, nil)
  end,

}
local tey__jiming = fk.CreateTriggerSkill{
  name = "tey__jiming",
  frequency = Skill.Wake,
  events = {fk.AfterCardsMove},
  can_trigger = function(self, event, target, player, data)
    if player:hasSkill(self) and
       player:usedSkillTimes(self.name, Player.HistoryGame) == 0 then
        local ids = {}
        for _, move in ipairs(data) do
          if move.to == player.id and move.toArea == Player.Hand then
            for _, info in ipairs(move.moveInfo) do
              if table.contains(player:getCardIds("h"), info.cardId) and Fk:getCardById(info.cardId).trueName == "slash" then
                table.insertIfNeed(ids, info.cardId)
            end
          end
        end
      end
      if #ids > 0 then
        return true
      end
     end
    end,
  can_wake = function(self, event, target, player, data)
    return player:getMark("@jiming_slash") >= 6
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:handleAddLoseSkills(player, "tey__range", nil, true, false)
    room:setPlayerMark(player,"@jiming_slash", 0)
  end,

  refresh_events = {fk.AfterCardsMove, fk.TurnEnd},
  can_refresh = function(self, event, target, player, data)
    if player:hasSkill(self) then
      if event == fk.AfterCardsMove and player:usedSkillTimes(self.name, Player.HistoryGame) == 0 then
      local ids = {}
      for _, move in ipairs(data) do
        if move.to == player.id and move.toArea == Player.Hand then
         for _, info in ipairs(move.moveInfo) do
            if table.contains(player:getCardIds("h"), info.cardId) and Fk:getCardById(info.cardId).trueName == "slash" then
              table.insertIfNeed(ids, info.cardId)
          end
        end 
      end
    end
    if #ids > 0 then
      return true
    end
  elseif event == fk.TurnEnd then
    return target == player and not target.dead
    and player:getMark("jiming_roar") > 0
    end
  end
  end,
  on_refresh = function(self, event, target, player, data)
    local room = player.room
    if event == fk.AfterCardsMove then
    local ids = {}
      for _, move in ipairs(data) do
        if move.to == player.id and move.toArea == Player.Hand then
          for _, info in ipairs(move.moveInfo) do
            if table.contains(player:getCardIds("h"), info.cardId) and Fk:getCardById(info.cardId).trueName == "slash" then
              table.insertIfNeed(ids, info.cardId)
            end
          end
        end
     end
    room:addPlayerMark(player, "@jiming_slash", #ids)
  elseif event == fk.TurnEnd then
    room:setPlayerMark(player, "jiming_roar", 0)
    end
  end,
}
local tey__range = fk.CreateTriggerSkill{
  name = "tey__range",
  anim_type = "control",
  frequency = Skill.Compulsory,
  events = {fk.TargetSpecified},
  can_trigger = function(self, event, target, player, data)
    if not (target == player and player:hasSkill(self)) then return false end
    if data.card.trueName == "slash" and #AimGroup:getAllTargets(data.tos) == 1 then
      local to = player.room:getPlayerById(data.to)
      return not to.dead
    end
  end,
  on_use = function(self, event, _, player, data)
    local room = player.room
    local target = room:getPlayerById(data.to)
    local choices = {}
    local skillnumber = {}
    for _, skill in ipairs(target.player_skills) do
      if skill:isPlayerSkill(target) and skill.visible then
        if not (type(target:getMark("range_perish-turn")) == "table" and table.contains(target:getMark("range_perish-turn"), skill.name)) then
          table.insertIfNeed(skillnumber, skill.name)
        end
      end
    end
    if #skillnumber > 0 then
      table.insert(choices, "range-perish")
    end
    if target:getMark("@@range_vanish-round") == 0 then
      table.insert(choices, "range-vanish")
    end
    if #choices > 0 then
      local choice = room:askForChoice(player, choices, self.name, self.name, false, {"range-perish", "range-vanish"})
      if choice == "range-perish" then
        local choice1 = room:askForChoice(player, skillnumber, self.name, "#range-choice::"..target.id, true)
        local skills1 = player:getTableMark("range_perish-turn")
        table.insertIfNeed(skills1, choice1)
        room:setPlayerMark(target, "range_perish-turn", skills1)
        local skillnumby = {}
        for _, s in ipairs(player.player_skills) do
          if s:isPlayerSkill(player) then
            if not (type(player:getMark("range_perish-turn")) == "table" and table.contains(player:getMark("range_perish-turn"), s.name)) then
              table.insertIfNeed(skillnumby, s.name)
            end
          end
        end
        local choice2 = room:askForChoice(player, skillnumby, self.name, "#range-choice::"..player.id, true)
        table.insertIfNeed(skills1, choice2)
        room:setPlayerMark(player, "range_perish-turn", skills1)
    elseif choice == "range-vanish" then
      room:setPlayerMark(target, "@@range_vanish-round", 1)
      room:setPlayerMark(player, "@@range_vanish-round", 1)
    end
   end
  end,
}
local range_trigger = fk.CreateTriggerSkill{
  name = "#range_trigger",
  mute = true,
  events = {fk.PreHpRecover},
  can_trigger = function(self, event, target, player, data)
    return target == player and player:getMark("@@range_vanish-round") > 0 and not player.dying
  end,
  on_cost = Util.TrueFunc,
  on_use = function(self, event, target, player, data)
    return true
  end,
}
local range_invalidity = fk.CreateInvaliditySkill {
  name = "#range_invalidity",
  invalidity_func = function(self, from, skill)
    local mark = from:getMark("range_perish-turn")
    return type(mark) == "table" and table.contains(mark, skill.name)
  end
}
local tey__shihuan = fk.CreateTriggerSkill{
  name = "tey__shihuan$",
  anim_type = "support",
  frequency = Skill.Limited,
  events = {fk.EnterDying},
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(self) and target.dying and
    target.kingdom == "Natlan" and target ~= player
    and player:usedSkillTimes(self.name, Player.HistoryGame) == 0
  end,
  on_cost = function(self, event, target, player, data)
    return player.room:askForSkillInvoke(player, self.name, nil, "#shihuan-invoke::"..target.id)
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local targets = table.map(table.filter(room.alive_players, function (p)
      return p:isWounded() and p.kingdom == "Natlan"
    end), Util.IdMapper)
    local tos = room:askForChoosePlayers(
      player,
      targets,
      1,
      2,
      "#shihuan-choose",
      self.name,
      false
    )
    for _, pid in ipairs(tos) do
    local top = room:getPlayerById(pid)
    if not top.dead and top:isWounded() and #tos == 2 then
      room:recover({
        who = top,
        num = 1,
        recoverBy = player,
        skillName = self.name
      })
    elseif not top.dead and top:isWounded() and #tos == 1 then
      room:recover({
        who = top,
        num = 2,
        recoverBy = player,
        skillName = self.name
      })
    end
   end
  end,
}


tey__range:addRelatedSkill(range_trigger)
tey__range:addRelatedSkill(range_invalidity)
Mavuika:addSkill(tey__chipo)
Mavuika:addSkill(tey__jiming)
Mavuika:addSkill(tey__shihuan)
Mavuika:addRelatedSkill(tey__range)

Fk:loadTranslationTable{
  ["tey__Mavuika"] = "玛薇卡", 
  ["#tey__Mavuika"] = "焚夜以炎",
  ["cv:tey__Mavuika"] = "李晔",
  ["illustrator:tey__Mavuika"] = "鱼鹅BABA",
  ["designer:tey__Mavuika"] = "幽蝶化烬",

  ["tey__chipo"] = "炽魄",
  [":tey__chipo"] = "锁定技，你装备区牌数或体力值变化后，随机获得一个含有“获得”与“【杀】”的二字技能（上限为2，发动后失去，若获得过则改为获得一张【杀】）。",
  ["@[:]tey__chipo"] = "炽魄",
  ["#tey__chipo-lose"] = "炽魄：额外获得的技能已超出上限，请选择 %arg 个技能失去！",
  ["tey__jiming"] = "集名",
  [":tey__jiming"] = "觉醒技，你得到【杀】后，若你累计得到至少六张【杀】，你获得“燃歌”。",
  ["@jiming_slash"] = "集名",
  ["tey__range"] = "燃歌",
  [":tey__range"] = "出牌阶段，你可以失去一个技能，获得此技能描述中的一张牌，令一名其他角色选择一项：1.成为你下张【杀】的额外目标；2.你令其的一个技能本回合失效；3.令你此次获得的牌无次数限制。",
  ["range-perish"] = "与目标角色各一个技能本回合失效",
  ["range-vanish"] = "与目标角色本轮不能于非濒死状态回复体力",
  ["#range-choice"] = "您选择了 燃歌 无效技能的选项，请选择 %dest 的一个技能，此技能于本回合失效",
  ["@@range_vanish-round"] = "燃歌 同死",
  ["tey__shihuan"] = "还火",
  [":tey__shihuan"] = "主公技，限定技，纳塔角色进入濒死时，你可以令纳塔角色的【杀】视为【桃】直至其使用牌。",
  ["#shihuan-invoke"] = "还火：%dest 濒死，可发动还魂诗为纳塔角色回复共计2点体力",
  ["#shihuan-choose"] = "还火：请选择至多两名角色，选择角色数若为1/2，这些角色回复2/1点体力。",

  ["$tey__chipo1"] = "长路向前延续，旅途正待新篇。",
  ["$tey__chipo2"] = "成为火之前，请先为自我的存在而骄傲。",
  ["$tey__jiming1"] = "恭听太阳的轰鸣！",
  ["$tey__jiming2"] = "埋葬于赤焰之下！",
  ["$tey__range1"] = "焚灭不净！",
  ["$tey__range2"] = "谁要阻拦？",
  ["$tey__range3"] = "点燃吧。",
  ["$tey__range4"] = "烈日随我。",
  ["$tey__shihuan1"] = "神明总是在天上待着，不常来地上走走可不行。",
  ["$tey__shihuan2"] = "现任火神玛薇卡，助你的视野中再无漆黑。",
  ["~tey__Mavuika"] = "传承，终结了吗？",
} 
--考虑到代码稳定性以及机制交互的统一（起码让本扩的阴阳转换有机会和邀弈复纂进行联动），
--本扩的所有多项转换技均改为非标签类技能，可惜刻晴的多项转换/转换技周始和二技能的联动也没有了，只能强行保留序号摸牌

--刻晴【折进】
local tey__zhejin = fk.CreateViewAsSkill{
  name = "tey__zhejin",
  mute = true,
  anim_type = "control",
  prompt = "#tey__zhejin-viewas",
  pattern = ".|.|.|.|.|basic",
  interaction = function()
    local all_names = {}
    all_names = U.getAllCardNames("b")
    local names = U.getViewAsCardNames(Self, "tey__zhejin", all_names)
    if #names > 0 then
      return UI.ComboBox { choices = names, all_choices = all_names }
    end
  end,
  card_filter = Util.FalseFunc,
  view_as = function(self, cards)
    if not self.interaction.data then return end
    local card = Fk:cloneCard(self.interaction.data)
    card.skillName = self.name
    return card
  end,
  before_use = function(self, player)
    local room = player.room
       if player:getMark("@@tey__zhejin1") == 1 then
        player:broadcastSkillInvoke(self.name, 1)
        room:setPlayerMark(player, "@@tey__zhejin1", 0)
        room:setPlayerMark(player, "@@tey__zhejin3", 0)
        room:setPlayerMark(player, "@@tey__zhejin2", 1)
        room:askForDiscard(player, 1, 1, false, self.name, false, ".|.|.|.|.|basic", "#zhejin-discard:::")
   elseif player:getMark("@@tey__zhejin2") == 1 then
        player:broadcastSkillInvoke(self.name, 2)
        room:setPlayerMark(player, "@@tey__zhejin1", 0)
        room:setPlayerMark(player, "@@tey__zhejin2", 0)
        room:setPlayerMark(player, "@@tey__zhejin3", 1)
        local bas = room:askForCard(player, 1, 1, false, self.name, false,".|.|.|.|.|basic", "#zhejin-recast:::")
        room:recastCard(bas, player, self.name)
        local tar = table.filter(room.alive_players, function(p) return (#p.player_cards[Player.Hand] >= 1 ) end)
        local tos = room:askForChoosePlayers(player, table.map(tar, Util.IdMapper), 1, 1, "#tey__zhejin-choose", self.name, false)
        local to = room:getPlayerById(tos[1])
        room:askForDiscard(to, 2, 2, false, self.name, false)
  elseif player:getMark("@@tey__zhejin3") == 1 then
        player:broadcastSkillInvoke(self.name, 3)
        room:setPlayerMark(player, "@@tey__zhejin3", 0)
        room:setPlayerMark(player, "@@tey__zhejin2", 0)
        room:setPlayerMark(player, "@@tey__zhejin1", 1)
        local tar = table.filter(room.alive_players, function(p) return (#p.player_cards[Player.Hand] >= 1 ) end)
        if #tar >= 1 then 
        local tos = room:askForChoosePlayers(player, table.map(tar, Util.IdMapper), 1, 1, "#tey__zhejin-choose", self.name, false)
        local to = room:getPlayerById(tos[1])
        if to:getHandcardNum() == 1 then
          local recast = room:askForCard(to, 1, 1, false, self.name, false,".|.|.|.|.|", "#tey__zhejin-recast")
          room:recastCard(recast, to, self.name)
        elseif to:getHandcardNum() >= 2 then
          local recast = room:askForCard(to, 2, 2, false, self.name, false,".|.|.|.|.|", "#tey__zhejin-recast")
          room:recastCard(recast, to, self.name)
        end
        end
        end
    if player:getMark("@@tey__zhejin1") ~= 1 then return "" end
    end,
  on_use = function(self, event, target, player, data)
    tey__zhejin:use(event, target, player, data)
  end,
  enabled_at_play = function(self, player)
    if player:usedSkillTimes(self.name, Player.HistoryTurn) < 2 then
      local can = table.find(player.player_cards[Player.Hand], function(id) return Fk:getCardById(id).type == Card.TypeBasic 
        and not player:prohibitDiscard(Fk:getCardById(id)) end)
      local cann = table.find(player.player_cards[Player.Hand], function(id) return Fk:getCardById(id).type == Card.TypeBasic end)
        return (player:getMark("@@tey__zhejin2") == 1 and cann) or player:getMark("@@tey__zhejin3") == 1
        or (player:getMark("@@tey__zhejin1") == 1 and can)
      end
  end,
  enabled_at_response = function(self, player, res)
    if not res and player:usedSkillTimes(self.name, Player.HistoryTurn) < 2 then
      local can = table.find(player.player_cards[Player.Hand], function(id) return Fk:getCardById(id).type == Card.TypeBasic 
        and not player:prohibitDiscard(Fk:getCardById(id)) end)
      local cann = table.find(player.player_cards[Player.Hand], function(id) return Fk:getCardById(id).type == Card.TypeBasic end)
      return (player:getMark("@@tey__zhejin2") == 1 and cann) or player:getMark("@@tey__zhejin3") == 1
      or (player:getMark("@@tey__zhejin1") == 1 and can)
      end
  end,

  on_acquire = function (self, player, is_start)
    local room = player.room
      room:setPlayerMark(player, "@@tey__zhejin1", 1)
      room:setPlayerMark(player, "@@tey__zhejin2", 0)
      room:setPlayerMark(player, "@@tey__zhejin3", 0)
  end,

  on_lose = function (self, player, is_death)
    local room = player.room
      room:setPlayerMark(player, "@@tey__zhejin1", 0)
      room:setPlayerMark(player, "@@tey__zhejin2", 0)
      room:setPlayerMark(player, "@@tey__zhejin3", 0)
      player:setSkillUseHistory(self.name, 0, Player.HistoryTurn)
  end,
}

local tey__biaofa = fk.CreateActiveSkill{
  name = "tey__biaofa",
  mute = true,
  anim_type = "offensive",
  card_num = 3,
  target_num = 0,
  interaction = function(self)
    return UI.ComboBox {choices = {"ready_skill_reset", "ready_skill_check"}}
  end,
  can_use = function(self, player)
    return player:usedSkillTimes("#tey__biaofa_true", Player.HistoryGame) > 0 and player:usedSkillTimes("#tey__biaofa_true", Player.HistoryRound) == 0
  end,
  card_filter = function(self, to_select, selected)
    if self.interaction.data == "ready_skill_reset" then
    return #selected < 3 and not Self:prohibitDiscard(Fk:getCardById(to_select))
    elseif self.interaction.data == "ready_skill_check" then
    return false
    end
  end,
  target_filter = Util.FalseFunc,
  on_use = function(self, room, effect)
    local player = room:getPlayerById(effect.from)
    player:broadcastSkillInvoke(self.name, math.random(2))
    room:throwCard(effect.cards, self.name, player, player)
    if self.interaction.data == "ready_skill_reset" then
      player:setSkillUseHistory("#tey__biaofa_true", 0, Player.HistoryGame)
      player:setSkillUseHistory("#tey__biaofa_true", 0, Player.HistoryRound)
    room:setPlayerMark(player, "@@tey__biaofa_readying", 0)
    end
  end,
}
local tey__biaofa_true = fk.CreateTriggerSkill{
  name = "#tey__biaofa_true",
  anim_type = "offensive",
  events = {fk.TargetSpecifying},
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(self) and player:getMark("@@tey__biaofa_readying") == 0
    and data.firstTarget and data.card.is_damage_card
  end,
  on_cost = function(self, event, target, player, data)
    return player.room:askForSkillInvoke(player, self.name, nil, "#tey__biaofa_trues:")
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:setPlayerMark(player, "@@tey__biaofa_readying", 1)
    player:broadcastSkillInvoke("tey__biaofa", math.random(3,4))
    local targets = table.map(table.filter(room:getAllPlayers(), function(p)
      return not player:isProhibited(p, data.card) end), Util.IdMapper)
    local tos = room:askForChoosePlayers(player, targets, 0, 999,
      "#tey__biaofa_true-choose", self.name, false)
    for _, id in ipairs(AimGroup:getAllTargets(data.tos)) do
      AimGroup:cancelTarget(data, id)
    end
    for _, id in ipairs(tos) do
      AimGroup:addTargets(room, data, id)
    end
  end,

  refresh_events = {fk.AfterDrawPileShuffle},
  can_refresh = function(self, event, target, player, data)
    return player:getMark("@@tey__biaofa_readying") > 0
  end,
  on_refresh = function(self, event, target, player, data)
    local room = player.room
      room:setPlayerMark(player, "@@tey__biaofa_readying", 0)
      player:setSkillUseHistory("#tey__biaofa_true", 0, Player.HistoryGame)
      player:setSkillUseHistory("#tey__biaofa_true", 0, Player.HistoryRound)
  end,

  on_lose = function (self, player, is_death)
    local room = player.room
      room:setPlayerMark(player, "@@tey__biaofa_readying", 0)
      player:setSkillUseHistory("#tey__biaofa_true", 0, Player.HistoryGame)
      player:setSkillUseHistory("#tey__biaofa_true", 0, Player.HistoryRound)
  end,
}
local tey__keqin = fk.CreateTriggerSkill{
  name = "tey__keqin",
  anim_type = "defensive",
  events = {fk.CardUseFinished},
  can_trigger = function(self, event, target, player, data)
    if target == player and player:hasSkill(self) then
      return data.card and not U.isPureCard(data.card)
    end
  end,
  on_cost = function(self, event, target, player, data)
    local to = player.room:askForChoosePlayers(player, table.map(player.room:getAlivePlayers(), Util.IdMapper), 1, 1, "#keqin-choose", self.name, true)
    if #to > 0 then
      self.cost_data = to[1]
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local to = room:getPlayerById(self.cost_data)
    local cards = room:getCardsFromPileByRule(data.card.name, 1, "allPiles")
    if #cards > 0 then
      room:moveCards({
        ids = cards,
        to = to.id,
        toArea = Card.PlayerHand,
        moveReason = fk.ReasonJustMove,
        proposer = player.id,
        skillName = self.name,
      })
      if player:usedSkillTimes(self.name, Player.HistoryTurn) >= 1 and
      player:usedSkillTimes("#tey__keqin_renew", Player.HistoryTurn) >= 1 then
        if player:getMark("@@tey__zhejin1") == 1 then
          player:drawCards(1, self.name)
        elseif player:getMark("@@tey__zhejin2") == 1 then
          player:drawCards(2, self.name)
        elseif player:getMark("@@tey__zhejin3") == 1 then
          player:drawCards(3, self.name)
        end
      end
    end
  end,
}
local tey__keqin_renew = fk.CreateTriggerSkill{
  name = "#tey__keqin_renew",
  anim_type = "support",
  events = {fk.AfterSkillEffect},
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill("tey__keqin") and (data.name == "tey__biaofa" or data.name == "rfenghou_ready_skill&")
  end,
  on_cost = function(self, event, target, player, data)
    local to = player.room:askForChoosePlayers(player, table.map(player.room:getAlivePlayers(), Util.IdMapper), 1, 1, "#keqin-renew", self.name, true)
    if #to > 0 then
      self.cost_data = to[1]
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    player:broadcastSkillInvoke("tey__keqin")
    local to = room:getPlayerById(self.cost_data)
    local skills = {}
    for _, s in ipairs(to.player_skills) do
      local str = Fk:translate(":"..s.name, "zh_CN")
      if s:isPlayerSkill(to) and (string.find(str, "蓄势技") or string.find(str, "重置技")) then
      table.insertIfNeed(skills, s.name)
    end
    end
    if #skills > 0 then
      room:handleAddLoseSkills(to, "-"..table.concat(skills, "|-"), nil, true, false)
      room:handleAddLoseSkills(to, table.concat(skills, "|"), nil, true, false)
    end
    if player:usedSkillTimes(self.name, Player.HistoryTurn) >= 1 and
    player:usedSkillTimes("tey__keqin", Player.HistoryTurn) >= 1 then
      if player:getMark("@@tey__zhejin1") == 1 then
        player:drawCards(1, self.name)
      elseif player:getMark("@@tey__zhejin2") == 1 then
        player:drawCards(2, self.name)
      elseif player:getMark("@@tey__zhejin3") == 1 then
        player:drawCards(3, self.name)
      end
    end
  end,
}

tey__biaofa:addRelatedSkill(tey__biaofa_true)
tey__keqin:addRelatedSkill(tey__keqin_renew)
Keqing:addSkill(tey__zhejin)
Keqing:addSkill(tey__biaofa)
Keqing:addSkill(tey__keqin)

Fk:loadTranslationTable{
  ["tey__Keqing"] = "刻晴", 
  ["#tey__Keqing"] = "霆霓快雨",
  ["cv:tey__Keqing"] = "谢莹",
  ["illustrator:tey__Keqing"] = "阿稳同学",
  ["designer:tey__Keqing"] = "幽蝶化烬",

  ["tey__zhejin"] = "折进",
  [":tey__zhejin"] = "<a href='transform_skill_href'>转换技</a>，每回合限两次，你需要使用基本牌时，你可以"..
  "①：弃置 ②：重铸 ③：视为使用需要的一张基本牌，若为②/③，你令一名角色弃置/重铸两张手牌。",
  ["#tey__zhejin-viewas"] = "请选择 折进 视为使用的基本牌（若为①/②，则作废且你弃置/重铸一张基本牌）",
  ["@@tey__zhejin1"] = "折进 ①",
  ["@@tey__zhejin2"] = "折进 ②",
  ["@@tey__zhejin3"] = "折进 ③",
  ["#zhejin-discard"] = "请执行 折进 ①的效果 弃置一张基本牌",
  ["#zhejin-recast"] = "请执行 折进 ②的效果 重铸一张基本牌",
  ["#tey__zhejin-choose"] = "请选择一名角色 令其 （当前显示若为：③/①） 弃置/重铸两张手牌",
  ["#tey__zhejin-recast"] = "请执行 折进 ③的效果 选择两张手牌重铸",
  ["tey__biaofa"] = "飙发",
  [":tey__biaofa"] = "<a href='ready_skill_href'>蓄势技</a>，你使用伤害类即时牌时，可以将目标改为任意名角色。",
  ["@@tey__biaofa_readying"] = "飙发 蓄势",
  ["#tey__biaofa_true"] = "飙发",
  ["#tey__biaofa_trues"] = "是否发动 飙发，修改此牌目标。",
  ["#tey__biaofa_true-choose"] = "是否发动 飙发，修改此牌目标为任意名角色（若不选择角色确定则取消所有目标）。",
  ["ready_skill_reset"] = "重置蓄势技（弃置三张牌）",
  ["ready_skill_check"] = "检查蓄势技（当前：蓄势中）",
  ["tey__keqin"] = "恪勤",
  [":tey__keqin"] = "你以弃牌重置蓄势技/使用转化或虚拟牌后，你可以令一名角色：复原其蓄势技与重置技/获得一张同名牌，"..
  "若本回合均执行过，你摸“折进”序号张牌。",
  ["#keqin-choose"] = "恪勤：请选择一名角色从牌堆或弃牌堆中获得你此次使用非纯实体牌的实体牌。",
  ["#keqin-renew"] = "恪勤：请选择一名角色复原其蓄势技，重置技（失去，再获得之）。",
  ["#tey__keqin_renew"] = "恪勤",


  ["$tey__zhejin1"] = "以退为进…",
  ["$tey__zhejin2"] = "调整战略吧。",
  ["$tey__zhejin3"] = "可别眨眼。",
  ["$tey__biaofa1"] = "一份付出，一份收获。",
  ["$tey__biaofa2"] = "收纳完毕，就重新出发吧。",
  ["$tey__biaofa3"] = "剑出，影随————",
  ["$tey__biaofa4"] = "剑光如我，斩尽芜杂!",
  ["$tey__keqin1"] = "心有所向，日复一日，必有精进。",
  ["$tey__keqin2"] = "劳逸结合是不错，但也别放松过头。",
  ["~tey__Keqing"] = "太不甘心了…",
} 

local tey__dengrui = fk.CreateTriggerSkill{
  name = "tey__dengrui",
  switch_skill_name = "tey__dengrui",
  anim_type = "switch",
  events = {fk.AfterCardTargetDeclared},
  can_trigger = function(self, event, target, player, data)
  local state = player:getSwitchSkillState(self.name, false, true)
  if player:hasSkill(self) and data.card and data.card.color == Card.Red and player:getMark("tey__dengrui_" .. state .. "-turn") < 2 then
      if player:getSwitchSkillState(self.name) == fk.SwitchYang then
        return data.card.subcards and (#data.card.subcards == 1 or not data.card:isVirtual()) and data.card.type == Card.TypeBasic
      elseif player:getSwitchSkillState(self.name) == fk.SwitchYin then
        return data.tos and #data.tos == 1 and data.card.type == Card.TypeTrick
      end
    end
  end,
  on_cost = function(self, event, target, player, data)
    if player:getSwitchSkillState(self.name) == fk.SwitchYang then
    return player.room:askForSkillInvoke(player, self.name, nil, "#tey__dengrui-await:")
  elseif player:getSwitchSkillState(self.name) == fk.SwitchYin then
    local pattern = ".|" .. data.card.number + 1  .. "~K"
    local c = player.room:askForCard(player, 1, 1, true, self.name, true, pattern, "#tey__dengrui-await:")
    if #c > 0 then
      self.cost_data = c[1]
      return true
    end
    end
  end,
  on_use = function(self, event, target, player, data)
    local state = player:getSwitchSkillState(self.name, true, true)
    player.room:addPlayerMark(player, "tey__dengrui_" .. state .. "-turn", 1)

    if player:getSwitchSkillState(self.name, true) == fk.SwitchYang then
      if data.card.is_damage_card then
        data.additionalDamage = (data.additionalDamage or 0) + 1
      elseif data.card.name == "peach" then
        data.additionalRecover = (data.additionalRecover or 0) + 1
      elseif data.card.name == "analeptic" then
        if data.extra_data and data.extra_data.analepticRecover then
          data.additionalRecover = (data.additionalRecover or 0) + 1
        else
          data.extra_data = data.extra_data or {}
          data.extra_data.additionalDrank = (data.extra_data.additionalDrank or 0) + 1
        end
      end
    elseif player:getSwitchSkillState(self.name, true) == fk.SwitchYin then
        if player.room:getCardArea(data.card) == Card.Processing then
        player.room:moveCardTo(self.cost_data, Card.DiscardPile, player, fk.ReasonJustMove, self.name, nil, true)
        player.room:obtainCard(player.id, data.card, true, fk.ReasonJustMove)
        end
      end
  end,
}

local tey__chuojin = fk.CreateTriggerSkill{
  name = "tey__chuojin",
  frequency = Skill.Limited,
  anim_type = "special",
  events = {fk.EventPhaseEnd},
  can_trigger = function(self, event, target, player, data)
    if event == fk.EventPhaseEnd and player.phase == Player.Draw then
    return player:hasSkill(self) and player:usedSkillTimes(self.name, Player.HistoryGame) == 0
    and target == player
    elseif event == fk.EventPhaseEnd and player.phase == Player.Discard then
    return player:hasSkill(self) and target == player
    and player:getMark("@tey__chuojin_ascending-turn") > 0 and player:getMark("@tey__chuojin-turn") >= 3
    end
  end,
  on_cost = function(self, event, target, player, data)
    if event == fk.EventPhaseEnd and player.phase == Player.Draw then
    local cards = player.room:askForDiscard(player, 2, 2, true, self.name, true, ".", "#tey__chuojin-invoke", false)
    if #cards == 2 then
      self.cost_data = cards
      return true
    end
  elseif event == fk.EventPhaseEnd and player.phase == Player.Discard then
    return true
    end
  end,
  on_use = function(self, event, target, player, data)
    if event == fk.EventPhaseEnd and player.phase == Player.Draw then
    player.room:setPlayerMark(player, "@@tey__chuojin_ascending-turn", 1)
  elseif event == fk.EventPhaseEnd and player.phase == Player.Discard then
    local choices = {"draw2"}
      if player:isWounded() then
        table.insert(choices, 1, "recover")
      end
      local reward = player.room:askForChoice(player, choices, self.name, "#tey__chuojin-reward", false, {"draw2", "recover"})
      U.rewardZhengsu(player, player, reward, self.name)
    local targets = {}
    for _, p in ipairs(player.room:getAlivePlayers()) do
      table.insert(targets, p.id)
    end
    local tos = player.room:askForChoosePlayers(player, targets, 2, 2, "#tey__chuojin-cost", self.name, true)
    if #tos == 2 then
      local target1, target2 = player.room:getPlayerById(tos[1]), player.room:getPlayerById(tos[2])
      local suit = {Fk:translate("log_diamond")}
      local number = {13}
      local mark1 = target1:getTableMark("@tey__chuojin")
      local mark2 = target2:getTableMark("@tey__chuojin")
      table.insertTableIfNeed(mark1, suit)
      table.insertTableIfNeed(mark2, number)
      player.room:setPlayerMark(target1, "@tey__chuojin", suit)
      player.room:setPlayerMark(target2, "@tey__chuojin", number)
    end
    end
  end,

  refresh_events = {fk.CardUsing},
  can_refresh = function(self, event, target, player, data)
    return target == player and player:usedSkillTimes(self.name, Player.HistoryTurn) > 0 and
      (player:getMark("@@tey__chuojin_ascending-turn") > 0 or player:getMark("@tey__chuojin_ascending-turn") > 0 )
  end,
  on_refresh = function(self, event, target, player, data)
    local room = player.room
    if data.card.number > 0 then
    room:addPlayerMark(player, "@tey__chuojin-turn", 1)
    if player:getMark("@@tey__chuojin_ascending-turn") > 0 then
      room:setPlayerMark(player, "@@tey__chuojin_ascending-turn", 0)
      if data.card.number then
        room:setPlayerMark(player, "@tey__chuojin_ascending-turn", data.card.number)
      end
    elseif player:getMark("@tey__chuojin_ascending-turn") > 0 then
      if data.card.number and data.card.number > player:getMark("@tey__chuojin_ascending-turn") then
        room:setPlayerMark(player, "@tey__chuojin_ascending-turn", data.card.number)
      elseif data.card.number and data.card.number <= player:getMark("@tey__chuojin_ascending-turn") then
        room:setPlayerMark(player, "@tey__chuojin_ascending-turn", 0)
      end
    end
    end
  end,
}
local tey__chuojin_change = fk.CreateFilterSkill{
  name = "#tey__chuojin_change",
  frequency = Skill.Compulsory,
  card_filter = function(self, to_select, player)
    local current = table.find(Fk:currentRoom().alive_players, function(p) return p.phase ~= Player.NotActive end)
    if current and table.contains(current:getTableMark("@tey__chuojin"), Fk:translate("log_diamond"))then
    return player:hasSkill(self) and (table.contains(player:getCardIds("h"), to_select.id))
    elseif current and table.contains(current:getTableMark("@tey__chuojin"), 13)then
    return player:hasSkill(self) and (table.contains(player:getCardIds("h"), to_select.id))
    end
  end,
  view_as = function(self, to_select)
    local current = table.find(Fk:currentRoom().alive_players, function(p) return p.phase ~= Player.NotActive end)
    if current and table.contains(current:getTableMark("@tey__chuojin"), Fk:translate("log_diamond")) then
    return Fk:cloneCard(to_select.name, Card.Diamond, to_select.number)
  elseif current and table.contains(current:getTableMark("@tey__chuojin"), 13)then
    return Fk:cloneCard(to_select.name, to_select.suit, 13)
    end
  end,
}
tey__chuojin:addRelatedSkill(tey__chuojin_change)
Jiaming:addSkill(tey__dengrui)
Jiaming:addSkill(tey__chuojin)


Fk:loadTranslationTable{
  ["tey__Jiaming"] = "嘉明", 
  ["#tey__Jiaming"] = "狻猊頕首",
  ["cv:tey__Jiaming"] = "谢莹",
  ["illustrator:tey__Jiaming"] = "解咕咕一",
  ["designer:tey__Jiaming"] = "幽蝶化烬",

  ["tey__dengrui"] = "登瑞",
  [":tey__dengrui"] = "转换技，每回合各限两次，一名角色使用红色牌时，若为：阳：一张牌的基本牌，你可以令此牌伤害或回复值+1；阴：一个目标的锦囊牌，你可以用点数更大的牌替换之。",
  ["#tey__dengrui-await"] = "是否发动 登瑞 （阳：增加此牌伤害与回复/阴：用点数更大的牌替换此牌）",
  ["tey__chuojin"] = "踔进",
  [":tey__chuojin"] = "限定技，摸牌阶段结束后，你可以弃置两张牌并执行擂进整肃。若成功，你可以选择两名角色，你的手牌于前者/后者的回合内花色视为♦/点数视为K。",
  ["#tey__chuojin-invoke"] = "是否发动 踔进，弃置两张牌，进行擂进整肃？",
  ["#tey__chuojin-reward"] = "发动 踔进，请选择整肃奖励",
  ["#tey__chuojin-cost"] = "发动 踔进，请选择两名角色，先选择的获得花色♦标记，后选择的获得点数K标记（于其回合内根据标记修改你的手牌信息）。",
  ["@@tey__chuojin_ascending-turn"] = "踔进 擂进",
  ["@tey__chuojin_ascending-turn"] = "踔进 擂进",
  ["@tey__chuojin-turn"] = "踔进已用",
  ["@tey__chuojin"] = "踔进",
  ["#tey__chuojin_change"] = "踔进",

  ["$tey__dengrui1"] = "不用运货的时候我一般在璃月港路边表演舞兽戏，赏个脸来看看?",
  ["$tey__dengrui2"] = "什么?!茶位费就算了，擦手帕都要另外收钱的?好在我自己有带，退掉退掉。",
  ["$tey__chuojin1"] = "哈哈，真看得起我啊，那我不练个砂煲那么大的拳头有点对不住你喔。",
  ["$tey__chuojin2"] = "走镖也是镖，保镖也是镖，信得过我的话，以后我来当你保镖咯?",
  ["~tey__Jiaming"] = "还没「采青」呢…",
} 

local tey__qingchang = fk.CreateTriggerSkill{
  name = "tey__qingchang",
  events = {fk.EventPhaseStart, fk.EventPhaseEnd},
  anim_type = "support",
  can_trigger = function(self, event, target, player, data)
    if target == player and player:hasSkill(self) then
      if event == fk.EventPhaseStart then
        return player.phase == Player.Start
      elseif event == fk.EventPhaseEnd then
        if player.phase == Player.Discard then
        return not player.dead and U.checkZhengsu(player, target, self.name)
        elseif player.phase == Player.Finish then
          return player:getMark("tey__qingchang-turn") > 0 and player:usedSkillTimes(self.name, Player.HistoryTurn) > 0
        end
      end
    end
  end,
  on_cost = function(self, event, target, player, data)
    if event == fk.EventPhaseStart and player.phase == Player.Start then
      return player.room:askForSkillInvoke(player, self.name, nil, "#tey__qingchang-invoke")
    elseif event == fk.EventPhaseEnd then
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    player.room:notifySkillInvoked(player, self.name)
    if event == fk.EventPhaseStart and player.phase == Player.Start then
      U.startZhengsu(player, player, self.name, "#tey__qingchang-choice")
    elseif event == fk.EventPhaseEnd then
      if player.phase == Player.Discard then
      local choices = {"draw2"}
      if player:isWounded() then
        table.insert(choices, 1, "recover")
      end
      local reward = player.room:askForChoice(player, choices, self.name, "#tey__qingchang-reward", false, {"draw2", "recover"})
      U.rewardZhengsu(player, player, reward, self.name)
      player.room:addPlayerMark(player, "tey__qingchang-turn")
    elseif player.phase == Player.Finish then
      local targets = table.filter(player.room.alive_players, function (p) 
        return player:distanceTo(p) == player:getMark("@tey__qingchang-turn") or player:distanceTo(p) == player:getMark("@tey__qingchang-turn") - 1 end)
      if #targets == 0 then return "" end
      targets = player.room:askForChoosePlayers(player, table.map(targets, Util.IdMapper), 1, 1,
      "#tey__qingchang-choose:", self.name, false)
      local target = player.room:getPlayerById(targets[1])
      local chooses = {"lost"}
      if target:isWounded() then
        table.insert(chooses, 1, "recover")
      end
      local song = player.room:askForChoice(player, chooses, self.name, "#tey__qingchang", false, {"lost", "recover"})
      if song == "lost" then
        player.room:loseHp(target, 1, self.name)
      else
        player.room:recover({
          who = target,
          num = 1,
          recoverBy = player,
          skillName = self.name
        })
      end
     end
    end
  end,
}
local tey__qingchang_refresh = fk.CreateTriggerSkill{
  name = "#tey__qingchang_refresh",

  refresh_events = {fk.AfterCardUseDeclared},
  can_refresh = function(self, event, target, player, data)
    return target == player and player:hasSkill(self, true) 
    and player:usedSkillTimes("tey__qingchang", Player.HistoryTurn) > 0
  end,
  on_refresh = function(self, event, target, player, data)
    player.room:addPlayerMark(player, "@tey__qingchang-turn")
  end,
}

local tey__lianyun = fk.CreateTriggerSkill{
  name = "tey__lianyun",
  events = {fk.AfterCardUseDeclared},
  can_trigger = function(self, event, target, player, data)
    local mark1 = player:getTableMark("@tey__lianyun1")
    local mark2 = player:getTableMark("@tey__lianyun2")
    return player == target and player:hasSkill(self) and (#mark1 > 0 or #mark2 > 0)
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
    local choices1 = {}
    local choices2 = {}
    local mark1 = player:getTableMark("@tey__lianyun1")
    for _, id1 in ipairs(mark1) do
      table.insertIfNeed(choices1, id1)
    end
    local mark2 = player:getTableMark("@tey__lianyun2")
    for _, id2 in ipairs(mark2) do
      table.insertIfNeed(choices2, id2)
    end
    local choices3 = {"cancel"}
    if #choices1 > 0 then
      table.insert(choices3, "numchange")
    end
    if #choices2 > 0 then
      table.insert(choices3, "suitchange")
    end
    local choice = room:askForChoice(player, choices3, self.name, "#tey__lianyun-invoke:")
    if choice == "cancel" then
      return false
    elseif choice == "suitchange" then
      local choice2 = room:askForChoice(player, choices2, self.name, "#tey__lianyun2:")
      table.removeOne(mark2, choice2)
      player.room:setPlayerMark(player, "@tey__lianyun2", #mark2 > 0 and mark2 or 0 )
      self.cost_data = choice2
      return true
    elseif choice == "numchange" then
      local choice1 = room:askForChoice(player, choices1, self.name, "#tey__lianyun1:")
      table.removeOne(mark1, choice1)
      player.room:setPlayerMark(player, "@tey__lianyun1", #mark1 > 0 and mark1 or 0 )
      self.cost_data = choice1
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local log = self.cost_data
    if not log or log == nil then return false end
    local card = Fk:cloneCard(data.card.name, data.card.suit, data.card.number)
    for k, v in pairs(data.card) do
      if card[k] == nil then
        card[k] = v
      end
    end
    if data.card:isVirtual() then
      card.subcards = data.card.subcards
    else
      card.id = data.card.id
    end
    card.skillNames = data.card.skillNames
    if log ~= "log_club" and log ~= "log_spade" and log ~= "log_heart" and log ~= "log_diamond" then
      card.number = tonumber(log)
    else
    local card_suits_reverse_table = {
      log_spade = 1,
      log_club = 2,
      log_heart = 3,
      log_diamond = 4,
    }
    local suit = card_suits_reverse_table[log]
      card.suit = suit
      if suit == Card.Diamond or suit == Card.Heart then
      card.color = Card.Red
      elseif suit == Card.Club or suit == Card.Spade then
      card.color = Card.Black
    end
    end
    data.card = card
  end,

  on_lose = function (self, player, is_death)
    player.room:setPlayerMark(player, "@tey__lianyun1" , 0)
    player.room:setPlayerMark(player, "@tey__lianyun2" , 0)
  end,
}

local tey__lianyun_start = fk.CreateTriggerSkill{
  name = "#tey__lianyun_start",
  anim_type = "special",
  events = {fk.RoundStart},
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill("tey__lianyun")
  end,
  on_cost = function(self, event, target, player, data)
    return player.room:askForSkillInvoke(player, self.name, nil, "#tey__lianyun_start-invoke")
  end,
  on_use = function(self, event, target, player, data)
    local choices = {"draw1"}
      if table.find(player.player_cards[Player.Hand], function(id) return player:canUse(Fk:getCardById(id)) end) then
        table.insert(choices, 1, "use1")
      end
      player:broadcastSkillInvoke("tey__lianyun")
      local choice = player.room:askForChoice(player, choices, self.name, "#tey__lianyun_startchoice", false, {"draw1", "use1"})
      local mark1 = player:getTableMark("@tey__lianyun1")
      local mark2 = player:getTableMark("@tey__lianyun2")
      if choice == "draw1" then
        local draw = player:drawCards(1, self.name)
        local card1 = Fk:getCardById(draw[1])
      if table.contains(mark1, tostring(card1.number))and table.contains(mark2, card1:getSuitString(true)) then
        player:drawCards(1, self.name)
      else
        table.insertIfNeed(mark1, tostring(card1.number))
        if card1.suit ~= Card.NoSuit then
        table.insertIfNeed(mark2, card1:getSuitString(true))
        end
      end
        player.room:setPlayerMark(player, "@tey__lianyun1", #mark1 > 0 and mark1 or 0 )
        player.room:setPlayerMark(player, "@tey__lianyun2", #mark2 > 0 and mark2 or 0 )
      else
        local card2 = U.askForUseRealCard(player.room, player, player:getCardIds("h"), ".", "tey__lianyun", "#tey__lianyun-card")
        if card2 then
          if table.contains(mark1, tostring(card2.card.number))and table.contains(mark2, card2.card:getSuitString(true)) then
            player:drawCards(1, self.name)
          else
          table.insertIfNeed(mark1, tostring(card2.card.number))
          if card2.card.suit ~= Card.NoSuit then
          table.insertIfNeed(mark2, card2.card:getSuitString(true))
          end
        end
          player.room:setPlayerMark(player, "@tey__lianyun1", #mark1 > 0 and mark1 or 0 )
          player.room:setPlayerMark(player, "@tey__lianyun2", #mark2 > 0 and mark2 or 0 )
        end
      end
  end,
}

tey__qingchang:addRelatedSkill(tey__qingchang_refresh)
tey__lianyun:addRelatedSkill(tey__lianyun_start)
Barbara:addSkill(tey__qingchang)
Barbara:addSkill(tey__lianyun)

Fk:loadTranslationTable{
  ["tey__Barbara"] = "芭芭拉", 
  ["#tey__Barbara"] = "闪耀偶像",
  ["cv:tey__Barbara"] = "宋媛媛",
  ["illustrator:tey__Barbara"] = "空亭",
  ["designer:tey__Barbara"] = "幽蝶化烬",

  ["tey__qingchang"] = "倾唱",
  [":tey__qingchang"] = "准备阶段，你可以整肃。若成功，你于结束阶段令一名与你距离为X或X-1的角色回复或失去1点体力。X为你本回合使用的牌数。",
  ["#tey__qingchang-invoke"] = "发动 倾唱，开始整肃，若成功，根据本回合用牌数令距离等于之的角色回血或掉血",
  ["#tey__qingchang-choice"] = "发动 倾唱，请选择一项整肃",
  ["#tey__qingchang-choose"] = "倾唱 请选择指定距离的角色，令其回复或失去1点体力",
  ["#tey__qingchang"] = "倾唱 请令该角色回复或失去1点体力",
  ["#tey__qingchang-reward"] = "发动 倾唱，请选择整肃奖励",
  ["lost"] = "失去体力",
  ["recover"] = "回复体力",
  ["draw2"] = "摸两张牌",
  ["use1"] = "使用一张牌",
  ["@tey__qingchang-turn"] = "倾唱距离",
  ["tey__lianyun"] = "连韵",
  [":tey__lianyun"] = "每轮开始时，你可以摸或使用一张牌并记录未记录的此牌花色点数，若均已记录则改为摸一张牌。"..
  "<br>你声明使用牌时，你可以移去一个花色或点数记录，令使用牌的花色或点数视为与之相同。",
  ["#tey__lianyun-invoke"] = "是否发动 连韵，修改此牌花色点数（若对应记录唯一则跳过选择询问）",
  ["suitchange"] = "修改此牌花色（花韵选一）",
  ["numchange"] = "修改此牌点数（点韵选一）",
  ["#tey__lianyun2"] = "请选择一个花韵记录，修改使用牌花色为对应值",
  ["#tey__lianyun1"] = "请选择一个点韵记录，修改使用牌点数为对应值",
  ["#tey__lianyun_start"] = "连韵",
  ["#tey__lianyun_start-invoke"] = "是否发动 连韵，摸牌或使用牌并记录此牌花色点数（不与现有记录重复）",
  ["#tey__lianyun_startchoice"] = "发动 连韵，请选择摸牌或使用牌",
  ["#tey__lianyun-card"] = "发动 连韵，请使用一张牌",
  ["@tey__lianyun1"] = "点韵",
  ["@tey__lianyun2"] = "花韵",

  ["$tey__qingchang1"] = "这样的好天气，嗯~适合比较明快的曲风呢!",
  ["$tey__qingchang2"] = "想用歌声，带给人们同样的惊喜。",
  ["$tey__qingchang3"] = "芭芭拉的舞步…治愈力UP!",
  ["$tey__qingchang4"] = "欸，想听我唱歌…?对不起，还…还没有到演出时间呢。",
  ["$tey__lianyun1"] = "演唱，开始!",
  ["$tey__lianyun2"] = "打起精神来哟!",
  ["$tey__lianyun3"] = "准备好了吗~",
  ["$tey__lianyun4"] = "♪哼哼哼~哼哼~",
  ["~tey__Barbara"] = "大家的声音，听不到呢…",
} 

local tey__michi = fk.CreateTriggerSkill{
  name = "tey__michi",
  anim_type = "offensive",
  events = {fk.CardUseFinished},
  can_trigger = function(self, event, target, player, data)
    local room = player.room
    local no_skill
    local mmmm
    local cardlist = data.card:isVirtual() and data.card.subcards or {data.card.id}
    if player:hasSkill(self) and target:getMark("tey__michi-round") == 0 then
      if #cardlist == 0 or not U.isPureCard(data.card) then return true end
    end 
    room.logic:getCurrentEvent():searchEvents(GameEvent.MoveCards, 1, function(e)
      if e.parent and e.parent.id == room.logic:getCurrentEvent().id then
        local subcheck = table.simpleClone(cardlist)
        for _, move in ipairs(e.data) do
          if move.moveReason == fk.ReasonUse then
            mmmm = room:getPlayerById(move.from)
          end
          for _, info in ipairs(move.moveInfo) do
            if table.removeOne(subcheck, info.cardId) then
              if mmmm == target then
                no_skill = true
              end
            end
          end
        end
        if #subcheck == 0 then
          return true
        end
      end
    end)
    if player:hasSkill(self) and target:getMark("tey__michi-round") == 0 then
      if mmmm ~= target and not no_skill then return true end
    end
  end,
  on_cost = function(self, event, target, player, data)
    return player.room:askForSkillInvoke(player, self.name, nil, "#tey__michi::"..target.id)
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:addPlayerMark(target, "tey__michi-round", 1)
    local choices = {"1","2"}
    local choice = player.room:askForChoice(player, choices, self.name, "#tey__michi-choicemax::"..target.id,
    false, {"1","2"})
    room:addPlayerMark(target, MarkEnum.MinusMaxCards.."-turn", tonumber(choice))
    target:drawCards(math.min(target:getMaxCards(), 3), self.name)
  end,
}

local tey__jianxin_sincereTreatSkill = fk.CreateActiveSkill{
  name = "tey__jianxin_sincereTreatSkill",
  prompt = "#sincere_treat_skill",
  target_num = 1,
  mod_target_filter = function(self, to_select, selected, user, card)
    return not Fk:currentRoom():getPlayerById(to_select):isAllNude()
  end,
  target_filter = Util.TargetFilter,
  on_effect = function(self, room, effect)
    local player = room:getPlayerById(effect.from)
    local target = room:getPlayerById(effect.to)
    if player.dead or target.dead or target:isAllNude() then return end
    local cards = room:askForCardsChosen(player, target, 1, 2, "hej", self.name)
    room:obtainCard(player, cards, false, fk.ReasonPrey)
   for _, id in ipairs(cards) do
      if Fk:getCardById(id):getMark("@@ShownCards-inhand") == 0 then 
      player.room:setCardMark(Fk:getCardById(id), "@@ShownCards-inhand", 1)
      end
    end
    if not player.dead and not target.dead or player:isKongcheng() then
      local n = math.min(#cards, player:getHandcardNum())
      cards = room:askForCard(player, n, n, false, self.name, false, ".|.|.|hand", "#sincere_treat-give::"..target.id..":"..n)
      room:obtainCard(target, cards, false, fk.ReasonGive)
    for _, id in ipairs(cards) do
        if Fk:getCardById(id):getMark("@@ShownCards-inhand") == 0 then
        player.room:setCardMark(Fk:getCardById(id), "@@ShownCards-inhand", 1)
        end
      end
    end
  end,
}
tey__jianxin_sincereTreatSkill.cardSkill = true
Fk:addSkill(tey__jianxin_sincereTreatSkill)
local tey__jianxin = fk.CreateTriggerSkill{
  name = "tey__jianxin",
  anim_type = "offensive",
  events = {fk.AfterCardsMove, fk.HpChanged},
  can_trigger = function(self, event, target, player, data)
    if event == fk.AfterCardsMove then
    if player:hasSkill(self) and player:getHandcardNum() == player.hp and player.phase ~= Player.Discard 
    and not table.contains(player:getTableMark("tey__jianxin_num-round"), player:getHandcardNum()) then
      for _, move in ipairs(data) do
        if move.to == player.id and move.toArea == Card.PlayerHand then
          return true
        end
        if move.from == player.id then
          for _, info in ipairs(move.moveInfo) do
            if info.fromArea == Card.PlayerHand then
              return true
            end
          end
        end
      end
    end
  elseif event == fk.HpChanged then
    if player:hasSkill(self) and player:getHandcardNum() == player.hp and target == player and player.phase ~= Player.Discard 
    and not table.contains(player:getTableMark("tey__jianxin_num-round"), player:getHandcardNum()) then
      return true
    end
  end
  end,
  on_cost = function (self, event, target, player, data)
    local success, dat = player.room:askForUseViewAsSkill(player, "tey__jianxin_viewas", "#tey__jianxin", true, {bypass_times = true, bypass_distance = true})
    if success then
      self.cost_data = dat
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:addTableMark(player, "tey__jianxin_num-round", player:getHandcardNum())
    local dat = self.cost_data
    local card1 = Fk.skills["tey__jianxin_viewas"]:viewAs(dat.cards)
    local use1 = {from = player.id, tos = table.map(dat.targets, function(p) return {p} end), card = card1, extraUse = true}
    room:useCard(use1)
  end,
}
local tey__jianxin_viewas = fk.CreateViewAsSkill{
  name = "tey__jianxin_viewas",
  pattern = "sincere_treat",
  card_filter = Util.FalseFunc,
  view_as = function(self, cards)
    local card = Fk:cloneCard("sincere_treat")
    card.skillName = "tey__jianxin"
    card.skill = tey__jianxin_sincereTreatSkill
    return card
  end,
}

local tey__chengwang = fk.CreateViewAsSkill{
  name = "tey__chengwang",
  anim_type = "support",
  pattern = ".",
  prompt = function (self, selected_cards, selected_targets)
    if Self:usedSkillTimes(self.name, Player.HistoryGame) % 2 == 0 then
      return "#tey__chengwang1"
    else
      return "#tey__chengwang2"
    end
  end,
  interaction = function()
    local all_names = {"analeptic", "known_both"}
    local names = U.getViewAsCardNames(Self, "tey__chengwang", all_names, {})
    if #names > 0 then
      return U.CardNameBox { choices = names, all_choices = all_names }
    end
  end,
  card_filter = Util.FalseFunc,
  view_as = function(self, cards)
    if not self.interaction.data then return end
    local card = Fk:cloneCard(self.interaction.data)
    card.skillName = self.name
    card:addSubcards(table.filter(Self:getCardIds(Player.Hand), function(id)
      return Fk:getCardById(id):getMark("@@ShownCards-inhand") > 0
    end))
    return card
  end,
  before_use = function(self, player, use)
    local tos = player.room:askForChoosePlayers(player, table.map(table.filter(player.room:getOtherPlayers(player), function(p)
      return #table.filter(p:getCardIds(Player.Hand), function(id)
        return Fk:getCardById(id):getMark("@@ShownCards-inhand") > 0
      end) == #table.filter(player:getCardIds(Player.Hand), function(id)
        return Fk:getCardById(id):getMark("@@ShownCards-inhand") > 0
      end) and not p:hasSkill("tey__chengwang", true) end), Util.IdMapper), 1, 1, "#tey__chengwang-choose", self.name, false)
      local to = player.room:getPlayerById(tos[1])
    player.room:handleAddLoseSkills(to, "tey__chengwang", nil, false, true)
    if player:usedSkillTimes(self.name, Player.HistoryGame) % 2 == 0 then
    player.room:handleAddLoseSkills(player, "-tey__chengwang", nil, false, true)
    end
  end,
  enabled_at_play = function(self, player)
    return #table.filter(Self:getCardIds(Player.Hand), function(id)
      return Fk:getCardById(id):getMark("@@ShownCards-inhand") > 0
    end) > 0 and #table.filter(Fk:currentRoom().alive_players, function(p)
      return #table.filter(p:getCardIds(Player.Hand), function(id)
        return Fk:getCardById(id):getMark("@@ShownCards-inhand") > 0
      end) == #table.filter(Self:getCardIds(Player.Hand), function(id)
        return Fk:getCardById(id):getMark("@@ShownCards-inhand") > 0
      end) and not p:hasSkill("tey__chengwang", true) and p ~= self end) > 0
  end,
  enabled_at_response = function(self, player, response)
    return not response and #table.filter(Fk:currentRoom().alive_players, function(p)
      return #table.filter(p:getCardIds(Player.Hand), function(id)
        return Fk:getCardById(id):getMark("@@ShownCards-inhand") > 0
      end) == #table.filter(Self:getCardIds(Player.Hand), function(id)
        return Fk:getCardById(id):getMark("@@ShownCards-inhand") > 0
      end) and not p:hasSkill("tey__chengwang", true) and p ~= self end) > 0 and
      #table.filter(Self:getCardIds(Player.Hand), function(id)
      return Fk:getCardById(id):getMark("@@ShownCards-inhand") > 0
    end) > 0 and Fk.currentResponsePattern and 
    (Exppattern:Parse(Fk.currentResponsePattern):match(Fk:cloneCard("known_both"))
     or Exppattern:Parse(Fk.currentResponsePattern):match(Fk:cloneCard("analeptic")))
  end,
}

Fk:addSkill(tey__jianxin_viewas)
Citlali:addSkill(tey__michi)
Citlali:addSkill(tey__jianxin)
Citlali:addSkill(tey__chengwang)

Fk:loadTranslationTable{
  ["tey__Citlali"] = "茜特菈莉", 
  ["#tey__Citlali"] = "白星黑曜",
  ["cv:tey__Citlali"] = "柳知萧",
  ["illustrator:tey__Citlali"] = "miho",
  ["designer:tey__Citlali"] = "幽蝶化烬",

  ["tey__michi"] = "谜饬",
  [":tey__michi"] = "每轮每名角色限一次，一名角色使用牌后，若此牌为转化或虚拟牌或不为其的牌，你可以令其：本回合手牌上限-1~2，摸手牌上限张牌（至多三张）。",
  ["tey__jianxin"] = "见心",
  [":tey__jianxin"] = "每轮每个数值限一次，你于你弃牌阶段外手牌数或体力值变化后，若与另一项相等，你可以视为对一名角色使用【推心置腹】，明置因此获得的牌。",
  ["tey__chengwang"] = "承望",
  [":tey__chengwang"] = "你可以令一名明置手牌数等于你且大于0的其他角色获得“承望”，然后将所有明置手牌当【酒】或【知己知彼】使用。第偶数次发动后，你失去本技能。",
  ["#tey__michi"] = "是否对 %dest 发动 谜饬 ， 减少其本回合手牌上限，令其摸牌？",
  ["#tey__michi-choicemax"] = "对 %dest 发动 谜饬 ， 减少其本回合选择数值的手牌上限。",
  ["tey__jianxin_viewas"] = "见心",
  ["#tey__jianxin"] = "是否发动 见心 ，视为对一名角色使用【推心置腹】？",
  ["tey__jianxin_sincereTreatSkill"] = "推心置腹",
  ["#tey__chengwang-choose"] = "请令一名明置手牌数等于你的其他角色获得“承望”。",
  ["#tey__chengwang1"] = "承望：请选择视为使用的牌。",
  ["#tey__chengwang2"] = "承望：请选择视为使用的牌。本次发动后你失去本技能。",

  ["$tey__michi1"] = "某种？是你奶奶！",
  ["$tey__michi2"] = "你！我的家伙呢？怎么没带根棍子？！",
  ["$tey__jianxin1"] = "岁月献给小酒杯，借钱九出十三归。",
  ["$tey__jianxin2"] = "出神仪式对旁人来说还挺不稳定的，就不要太好奇了吧。",
  ["$tey__chengwang1"] = "其实我还是很节制的，起床到中午的时间内是不会喝酒的……",
  ["$tey__chengwang2"] = "今晚恶曜不显，地灵微眠，迷烟浅睡。是个好夜晚。",
  ["~tey__Citlali"] = "大地的谜烟啊……",
} 

local tey__yunyu = fk.CreateTriggerSkill{
  name = "tey__yunyu",
  anim_type = "support",
  events = {fk.EnterDying},
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(self) and target.dying and target ~= player
  end,
  on_cost = function(self, event, target, player, data)
    local success, dat = player.room:askForUseActiveSkill(player, "tey__yunyu_as", self.name, true)
    if success and dat then
      self.cost_data = dat
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local mark = player:getTableMark("@tey__yunyu")
    local suit = Fk:getCardById(self.cost_data.cards[1]):getSuitString(true)
    player:showCards(self.cost_data.cards)
    if table.insertIfNeed(mark, suit) then
    room:setPlayerMark(player, "@tey__yunyu", mark)
    end
    room:obtainCard(target, self.cost_data.cards[1], false, fk.ReasonGive)
    room:useVirtualCard("peach", nil, player, target, self.name, true)
  end,
}
local tey__yunyu_as = fk.CreateActiveSkill{
  name = "tey__yunyu_as",
  min_card_num = 1,
  max_card_num = 1,
  target_num = 0,
  card_filter = function(self, to_select, selected)
    return #selected == 0 and table.every(Fk:currentRoom().alive_players, function (p)
      return not table.contains(p:getTableMark("@tey__yunyu"), Fk:getCardById(to_select):getSuitString(true)) 
    end)
  end,
}
local tey__yunyu_trigger = fk.CreateTriggerSkill{
  name = "#tey__yunyu_trigger",

  refresh_events = {fk.GameStart, fk.EventAcquireSkill, fk.EventLoseSkill, fk.Deathed},
  can_refresh = function(self, event, target, player, data)
    if event == fk.GameStart then
      return player:hasSkill(self, true)
    elseif event == fk.EventAcquireSkill or event == fk.EventLoseSkill then
      return data == self
    else
      return target == player and player:hasSkill(self, true, true)
    end
  end,
  on_refresh = function(self, event, target, player, data)
    local room = player.room
    if event == fk.GameStart or event == fk.EventAcquireSkill then
      if player:hasSkill(self, true) then
        for _, p in ipairs(room:getOtherPlayers(player)) do
          room:handleAddLoseSkills(p, "tey__yunyu&", nil, false, true)
        end
      end
    elseif event == fk.EventLoseSkill or event == fk.Deathed then
      for _, p in ipairs(room:getOtherPlayers(player, true, true)) do
        room:handleAddLoseSkills(p, "-tey__yunyu&", nil, false, true)
      end
    end
  end,
}
local tey__yunyu_active = fk.CreateActiveSkill{
  name = "tey__yunyu&",
  anim_type = "support",
  card_num = 1,
  target_num = 1,
  can_use = function(self, player)
    return not player:isKongcheng()
  end,
  card_filter = function(self, to_select, selected)
    return #selected == 0 and table.every(Fk:currentRoom().alive_players, function (p)
      return not table.contains(p:getTableMark("@tey__yunyu"), Fk:getCardById(to_select):getSuitString(true)) 
    end)
  end,
  target_filter = function(self, to_select, selected)
    return #selected == 0 and to_select ~= Self.id and Fk:currentRoom():getPlayerById(to_select):hasSkill("tey__yunyu")
    and Fk:currentRoom():getPlayerById(to_select):isWounded()
  end,
  on_use = function(self, room, effect)
    local player = room:getPlayerById(effect.from)
    local target = room:getPlayerById(effect.tos[1])
    local mark = target:getTableMark("@tey__yunyu")
    local suit = Fk:getCardById(effect.cards[1]):getSuitString(true)
    player:showCards(effect.cards)
    if table.insertIfNeed(mark, suit) then
    room:setPlayerMark(target, "@tey__yunyu", mark)
    end
    player:broadcastSkillInvoke("tey__yunyu")
    room:obtainCard(target, effect.cards[1], false, fk.ReasonGive)
    room:useVirtualCard("peach", nil, player, target, self.name, true)  
  end,
}
local tey__guixin = fk.CreateTriggerSkill{
  name = "tey__guixin",
  anim_type = "switch",
  switch_skill_name = "tey__guixin",
  events = {fk.TurnEnd},
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(self) and player:getMark("@@tey__guixin-turn") > 0 and not player:isKongcheng()
  end,
  on_cost = function(self, event, target, player, data)
    return player.room:askForSkillInvoke(player, self.name, nil, "#tey__guixin-"..player:getSwitchSkillState(self.name,false,true))
  end,
  on_use = function(self, event, target, player, data)
    local cards = player.player_cards[Player.Hand]
    player:showCards(cards)
    local suits = {}
    for _, id in ipairs(cards) do
      local suit = Fk:getCardById(id).suit
      local suit1 = Fk:getCardById(player.player_cards[Player.Hand][1]):getSuitString(true)
        if (player:getSwitchSkillState(self.name, true) == fk.SwitchYang and table.contains(suits, suit))
        or (player:getSwitchSkillState(self.name, true) == fk.SwitchYin 
        and not table.every(player.player_cards[Player.Hand], function(id) return Fk:getCardById(id):getSuitString(true) == suit1 end)) then
          return false 
        else
          table.insert(suits, suit)
        end
      end
       if player:getSwitchSkillState(self.name, true) == fk.SwitchYang then
        local ids = {}
        player.room.logic:getEventsOfScope(GameEvent.MoveCards, 1, function (e)
        for _, move in ipairs(e.data) do
          if move.toArea == Card.DiscardPile then
            for _, info in ipairs(move.moveInfo) do
              table.insertIfNeed(ids, info.cardId)
            end
          end
        end
        return false
      end, Player.HistoryTurn)
      ids = table.filter(ids, function (id) return player.room:getCardArea(id) == Card.DiscardPile and Fk:getCardById(id):isCommonTrick() end)
      if #ids == 0 then return end
      U.askForUseRealCard(player.room, player, ids, ".", self.name, "#tey_guixin_use",
        {expand_pile = ids, bypass_times = true}, false, true)
        elseif player:getSwitchSkillState(self.name, true) == fk.SwitchYin then
          local mark = player:getTableMark("@tey__yunyu")
          local suit1 = Fk:getCardById(player.player_cards[Player.Hand][1]):getSuitString(true)
          if table.removeOne(mark, suit1) then
            player.room:setPlayerMark(player, "@tey__yunyu", #mark > 0 and mark or 0)
         end
      end
  end,

  refresh_events = {fk.AfterCardsMove},
  can_refresh = function(self, event, target, player, data)
    if player:hasSkill(self) and player:getMark("@@tey__guixin-turn") == 0 then
      for _, move in ipairs(data) do
        if (move.to == player.id and move.toArea ~= Card.PlayerJudge) then
          return true
        end
      end
    end
  end,
  on_refresh = function(self, event, target, player, data)
    player.room:setPlayerMark(player,"@@tey__guixin-turn", 1)
  end,

  on_lose = function (self, player, is_death)
    player.room:setPlayerMark(player, "@tey__yunyu" , 0)
  end,
}

Fk:addSkill(tey__yunyu_as)
Fk:addSkill(tey__yunyu_active)
tey__yunyu:addRelatedSkill(tey__yunyu_trigger)
Yaoyao:addSkill(tey__yunyu)
Yaoyao:addSkill(tey__guixin)

Fk:loadTranslationTable{
  ["tey__Yaoyao"] = "瑶瑶", 
  ["#tey__Yaoyao"] = "仙蕊玲珑",
  ["cv:tey__Yaoyao"] = "刘颐诺",
  ["illustrator:tey__Yaoyao"] = "issign",
  ["designer:tey__Yaoyao"] = "幽蝶化烬",

  ["tey__yunyu"] = "云遇",
  [":tey__yunyu"] = "每花色限一次：其他角色可以于出牌阶段展示并交给已受伤的你一张牌，视为对你使用【桃】；其他角色濒死时，你可以展示并交给其一张牌，视为对其使用【桃】。",
  ["tey__guixin"] = "桂馨",
  [":tey__guixin"] = "转换技，你获得过牌的回合结束后，你可以展示手牌，阳：若花色均不同，你可以使用一张本回合弃牌堆中的普通锦囊牌；阴：若花色均相同，重置〖云遇〗的此花色。",
  ["@tey__yunyu"] = "云遇",
  ["tey__yunyu&"] = "云遇",
  [":tey__yunyu&"] = "你可以交给已受伤的瑶瑶一张牌（不与已记录花色重复），视为对其使用【桃】。",
  ["tey__yunyu_as"] = "云遇",
  [":tey__yunyu_as"] = "你可以交给濒死角色一张牌（不与已记录花色重复），视为对其使用【桃】。",
  ["@@tey__guixin-turn"] = "桂馨",
  ["#tey__guixin-yang"] = "你可以展示手牌，然后（当前分支：阳，若花色均不同，你可以使用一张本回合弃牌堆中的普通锦囊牌）",
  ["#tey__guixin-yin"] = "你可以展示手牌，然后（当前分支：阴，若花色均相同，重置〖云遇〗的此花色。）",
  ["#tey_guixin_use"] = "请使用本回合弃牌堆的一张普通锦囊牌",

  ["$tey__yunyu1"] = "「明日复明日，明日何其多…」总之，快快行动起来吧。",
  ["$tey__yunyu2"] = "真奇怪，为什么总有人想寻仙问道呢?仙人不是到处都是吗?",
  ["$tey__guixin1"] = "月桂！该上咯！",
  ["$tey__guixin2"] = "都收好，不要落下哦！",
  ["~tey__Yaoyao"] = "有辱...师门...",
} 

--[[local tey__fuzou = fk.CreateTriggerSkill{
  name = "tey__fuzou",
  anim_type = "drawcard",
  events = {fk.TurnEnd},
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(self) and player:getMark("tey__fuzou-turn") > 0 and not player:isKongcheng()
  end,
  on_cost = function(self, event, target, player, data)
    return player.room:askForSkillInvoke(player, self.name, nil, "#tey__fuzou-invoke")
  end,
  on_use = function(self, event, target, player, data)
   local choices = {}
   if player:getMark("@@tey__fuzou_mingzhi") == 0 then table.insert(choices, "discard_mingzhi") end
   if player:getMark("@@tey__fuzou_anzhi") == 0 then table.insert(choices, "discard_anzhi") end
   if #choices < 1 then return false end
   local choice = player.room:askForChoice(player, choices, self.name, "#tey__fuzou-choice:",false,{"discard_mingzhi", "discard_anzhi"})
   local propmt 
   if choice == "discard_mingzhi" then
    propmt = "#tey__fuzou_turnover1"
   elseif choice == "discard_anzhi" then
    propmt = "#tey__fuzou_turnover2"
  end
   local cards = player.room:askForCard(player, 0, 999, false, self.name, false, nil, propmt)
   for _, id in ipairs(cards) do
     if Fk:getCardById(id):getMark("@@ShownCards-inhand") == 0 then
     player.room:setCardMark(Fk:getCardById(id), "@@ShownCards-inhand", 1)
     else
     player.room:setCardMark(Fk:getCardById(id), "@@ShownCards-inhand", 0)
   end
   end
   if choice == "discard_mingzhi" then
    player.room:setPlayerMark(player, "@@tey__fuzou_mingzhi", 1)
    local cards1 = table.filter(player:getCardIds("h"), function(id)
      local card = Fk:getCardById(id)
      return card:getMark("@@ShownCards-inhand") > 0 and not player:prohibitDiscard(card)
    end)
    local cards2 = table.filter(player:getCardIds("e"), function(id)
      local card = Fk:getCardById(id)
      return card:getMark("@@HiddenCards") == 0 and not player:prohibitDiscard(card)
    end)
    local cards3 = {}
    if #cards1 > 0 then table.insert(cards3, cards1) end
    if #cards2 > 0 then table.insert(cards3, cards2) end
    if #cards3 > 0 then
      player.room:throwCard(cards3, self.name, player, player)
    end
    elseif choice == "discard_anzhi" then
      player.room:setPlayerMark(player, "@@tey__fuzou_anzhi", 1)
      local cards4 = table.filter(player:getCardIds("h"), function(id)
        local card = Fk:getCardById(id)
        return card:getMark("@@ShownCards-inhand") == 0 and not player:prohibitDiscard(card)
      end)
      local cards5 = table.filter(player:getCardIds("e"), function(id)
        local card = Fk:getCardById(id)
        return card:getMark("@@HiddenCards") > 0 and not player:prohibitDiscard(card)
      end)
      local cards6 = {}
      if #cards4 > 0 then table.insert(cards6, cards4) end
      if #cards5 > 0 then table.insert(cards6, cards5) end
      if #cards6 > 0 then
        player.room:throwCard(cards6, self.name, player, player)
      end
   end
      local x = player:getHandcardNum()
      if x > 4 then
      player:drawCards(4, self.name)
      elseif x <= 4 then
      player:drawCards(x, self.name)
      end
      if table.every(player.room:getOtherPlayers(player), function (p)
        return p:getHandcardNum() < player:getHandcardNum() end) then
        player.room:addPlayerMark(player, "@@tey__fuzou_max", 1)
      else
        player.room:setPlayerMark(player, "@@tey__fuzou_max", 0)
      end
      if player:getMark("@@tey__fuzou_max") == 2 then
        player.room:setPlayerMark(player, "@@tey__fuzou_max", 0)
        player.room:handleAddLoseSkills(player, "-tey__fuzou", nil, false, true)
      end
      if player:getMark("@@tey__fuzou_mingzhi") == 1 and player:getMark("@@tey__fuzou_anzhi") == 1 then
        player.room:setPlayerMark(player, "@@tey__fuzou_mingzhi", 0)
        player.room:setPlayerMark(player, "@@tey__fuzou_anzhi", 0)
      end
  end,

  refresh_events = {fk.AfterCardsMove},
  can_refresh = function(self, event, target, player, data)
    if player:hasSkill(self) and player:getMark("tey__fuzou-turn") == 0 then
      for _, move in ipairs(data) do
        if move.from == player.id and move.to ~= player.id then
          for _, info in ipairs(move.moveInfo) do
            return info.fromArea ~= Card.PlayerJudge
          end
      elseif move.to == player.id then
          return move.toArea ~= Card.PlayerJudge
        end
      end
    end
  end,
  on_refresh = function(self, event, target, player, data)
    player.room:setPlayerMark(player, "tey__fuzou-turn", 1)
  end,

  on_lose = function (self, player, is_death)
    local room = player.room
      room:setPlayerMark(player, "@@tey__fuzou_max", 0)
      room:setPlayerMark(player, "@@tey__fuzou_mingzhi", 0)
      room:setPlayerMark(player, "@@tey__fuzou_mingzhi", 0)
  end,
}]]

local tey__fuzou = fk.CreateTriggerSkill{
  name = "tey__fuzou",
  switch_skill_name = "tey__fuzou",
  anim_type = "switch",
  events = {fk.TurnEnd},
  can_trigger = function(self, event, target, player, data)
    local cards1 = table.filter(player:getCardIds("h"), function(id) return Fk:getCardById(id):getMark("@@ShownCards-inhand") > 0 end)
    local cards2 = table.filter(player:getCardIds("h"), function(id) return Fk:getCardById(id):getMark("@@ShownCards-inhand") == 0 end)
    return player:hasSkill(self) and ((player:getSwitchSkillState(self.name, false) == fk.SwitchYang and #cards2 > #cards1) or
    (player:getSwitchSkillState(self.name, false) == fk.SwitchYin and #cards2 < #cards1))
  end,
  on_use = function(self, event, target, player, data)
    player:drawCards(2, self.name)
    if player.dead or player:isKongcheng() then return end
    local x = player:getHandcardNum() // 2
    local cards = player.room:askForCard(player, 0, x, false, self.name, false, nil, "#tey__fuzou_turnover")
    for _, id in ipairs(cards) do
      if Fk:getCardById(id):getMark("@@ShownCards-inhand") == 0 then
      player.room:setCardMark(Fk:getCardById(id), "@@ShownCards-inhand", 1)
      end
    end
    if table.every(player:getCardIds("h"), function (id) return Fk:getCardById(id):getMark("@@ShownCards-inhand") > 0 end) then
      local success, dat = player.room:askForUseActiveSkill(player, "teyvat__cardplace", "#tey__fuzou_move", true,
      {all_choices_exclu = {"PlaceEquip", "TrueDelay", "ToHand"}, only_card = player:getCardIds("h")})
        if success and dat then
        local choice = dat.interaction
        local to = player.room:getPlayerById(dat.targets[1])
        if choice == "PlaceEquip" then
        player.room:moveCardTo(dat.cards, Player.Equip, to, fk.ReasonJustMove, self.name, nil, true, player.id)
        elseif choice == "TrueDelay" then
        player.room:moveCardTo(dat.cards, Player.Judge, to, fk.ReasonJustMove, self.name, nil, true, player.id)
        elseif choice == "ToHand" then
        player.room:moveCardTo(dat.cards, Player.Hand, to, fk.ReasonGive, self.name, nil, true, player.id)
        end
      end
    end
  end,

  refresh_events = {fk.RoundEnd, fk.Damaged},
  can_refresh = function(self, event, target, player, data)
    return player:hasSkill(self) and ((event == fk.Damaged and target == player) or event == fk.RoundEnd)
  end,
  on_refresh = function(self, event, target, player, data)
    if player.room:askForSkillInvoke(player, self.name, nil, "#tey__fuzou-invoke") then
      player.room:setPlayerMark(player, MarkEnum.SwithSkillPreName..self.name, player:getSwitchSkillState(self.name, true))
      player:addSkillUseHistory(self.name, 1)
    end
  end,

}

Xinyan:addSkill(tey__fuzou)

Fk:loadTranslationTable{
  ["tey__Xinyan"] = "辛焱", 
  ["#tey__Xinyan"] = "扫弦示本真",
  ["cv:tey__Xinyan"] = "王雅欣",
  ["illustrator:tey__Xinyan"] = "絵茶漬け",
  ["designer:tey__Xinyan"] = "幽蝶化烬",

  ["tey__fuzou"] = "拂奏",
  --[":tey__fuzou"] = "<a href='renew_skill_href'>重置技</a>，你获得或失去过牌的回合结束后，你可以翻转任意张手牌，弃置所有{①明置牌②暗置牌}并翻倍手牌数"..
  --"（至多摸四张）。你连续发动后若均为手牌数唯一最大，失去本技能。",
  [":tey__fuzou"] = "转换技，每回合结束时，若你的暗置手牌与明置手牌，阳：前者更多；阴：后者更多，你可以摸两张牌并明置至多半数手牌。"..
  "然后若你的手牌均明置，你可以将一张手牌交出或移至场上。<br>每轮结束时或你受到伤害后，你可以转换本技能。",
  ["#tey__fuzou_turnover"] = "拂奏：您可以选择至多半数的手牌明置，不选牌确定则跳过。",
  ["#tey__fuzou_move"] = "拂奏：您可以将一张手牌置于一名角色的区域内！",
  ["#tey__fuzou-invoke"] = "拂奏：是否转换拂奏的当前状态？",
  [":tey__fuzou_yang"] = "转换技，每回合结束时，若你的暗置手牌与明置手牌，<font color=\"#E0DB2F\">阳：前者更多</font>；<font color=\"gray\">阴：后者更多</font>，"..
  "你可以摸两张牌并明置至多半数手牌。然后若你的手牌均明置，你可以将一张手牌交出或移至场上。<br>每轮结束时或你受到伤害后，你可以转换本技能。",
  [":tey__fuzou_yin"] = "转换技，每回合结束时，若你的暗置手牌与明置手牌，<font color=\"gray\">阳：前者更多</font>；<font color=\"#E0DB2F\">阴：后者更多</font>，"..
  "你可以摸两张牌并明置至多半数手牌。然后若你的手牌均明置，你可以将一张手牌交出或移至场上。<br>每轮结束时或你受到伤害后，你可以转换本技能。",
  --["@@tey__fuzou_max"] = "拂奏 最大",
  --["#tey__fuzou-invoke"] = "是否发动 拂奏，进行一场酣畅淋漓的摸弃表演",
  --["#tey__fuzou-choice"] = "请选择 拂奏 要弃置的牌，进行一场酣畅淋漓的摸弃表演（注意：先选择再调整明暗置！）",
  --["#tey__fuzou_turnover1"] = "选择任意张手牌，明置/暗置的切换至另一形态（调整后，你将弃置所有明置牌并翻倍手牌数）",
  --["#tey__fuzou_turnover2"] = "选择任意张手牌，明置/暗置的切换至另一形态（调整后，你将弃置所有暗置牌并翻倍手牌数）",
  --["discard_anzhi"] = "弃置所有暗置牌（包括装备区）",
  --["discard_mingzhi"] = "弃置所有明置牌（包括装备区）",
  --["@@tey__fuzou_mingzhi"] = "已弃明",
  --["@@tey__fuzou_anzhi"] = "已弃暗",

  ["$tey__fuzou1"] = "马上就要来演出了，你也一起来嗨吗？",
  ["$tey__fuzou2"] = "热情还不够！",
  ["$tey__fuzou3"] = "为反抗高歌！",
  ["$tey__fuzou4"] = "听我的最强音！",
  ["~tey__Xinyan"] = "还不够，激昂…",
} 

local tey__yinrun = fk.CreateTriggerSkill{
  name = "tey__yinrun",
  anim_type = "special",
  mute = true,
  frequency = Skill.Compulsory,
  events = {fk.EventPhaseStart},
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(self) and (player.phase == Player.Start or player.phase == Player.Finish)
  end,
  on_use = function(self, event, target, player, data)
    if player.phase == Player.Start then
      player:broadcastSkillInvoke(self.name, math.random(2))
    local room = player.room
    local cards = player.player_cards[Player.Hand]
    local x1 = 0 
    local mark1 = player:getTableMark("@$tey__yinruncard1-turn")
      for _, id in ipairs(cards) do
        table.insertIfNeed(mark1, Fk:getCardById(id).name)
        x1 = x1 + Fk:getCardById(id).number
      end
    room:setPlayerMark(player, "@tey__yinrunnum1-turn", x1)
    room:setPlayerMark(player, "@$tey__yinruncard1-turn", #mark1 and mark1 or 0)
    player:showCards(cards)
    elseif player.phase == Player.Finish then
      player:broadcastSkillInvoke(self.name, math.random(2))
    local room = player.room
    local cards = player.player_cards[Player.Hand]
    local x2 = 0 
    local mark1 = player:getTableMark("@$tey__yinruncard1-turn")
    local mark2 = player:getTableMark("@$tey__yinruncard2-turn")
      for _, id in ipairs(cards) do
        table.insertIfNeed(mark2, Fk:getCardById(id).name)
        x2 = x2 + Fk:getCardById(id).number
      end
    room:setPlayerMark(player, "@tey__yinrunnum2-turn", x2)
    room:setPlayerMark(player, "@$tey__yinruncard2-turn", #mark2 and mark2 or 0)
    player:showCards(cards)
    if player:usedSkillTimes(self.name, Player.HistoryTurn) > 1 then
      local numsuccess = math.max(player:getMark("@tey__yinrunnum1-turn") - player:getMark("@tey__yinrunnum2-turn"),
      player:getMark("@tey__yinrunnum2-turn") - player:getMark("@tey__yinrunnum1-turn"))
    if numsuccess <= player:getLostHp() then
      local to1 = room:askForChoosePlayers(player, table.map(room:getAllPlayers(), Util.IdMapper), 1, 1,
      "#tey__yinrunstack-choose", self.name, false)
      room:setPlayerMark(room:getPlayerById(to1[1]), "@@tey__yinrunstack", 1)
    end
    local namesuccess = false
    for _, id2 in ipairs(mark2) do
    if not table.contains(mark1, id2) then
      namesuccess = true
    end
    end
    for _, id1 in ipairs(mark1) do
      if not table.contains(mark2, id1) then
        namesuccess = true
      end
    end
    if namesuccess then
      local to2 = room:askForChoosePlayers(player, table.map(room:getAllPlayers(), Util.IdMapper), 1, 1,
      "#tey__yinrunrecover-choose", self.name, false)
      room:setPlayerMark(room:getPlayerById(to2[1]), "@@tey__yinrunhp", 1)
      if numsuccess <= player:getLostHp() then
        local subtype_string_table = {
          [Card.SubtypeArmor] = "armor",
          [Card.SubtypeWeapon] = "weapon",
          [Card.SubtypeTreasure] = "treasure",
          [Card.SubtypeDelayedTrick] = "delayed_trick",
          [Card.SubtypeDefensiveRide] = "defensive_ride",
          [Card.SubtypeOffensiveRide] = "offensive_ride",
        }
        for _, slot in ipairs(player:getAvailableEquipSlots()) do
          if player.dead then return end
          local type = Util.convertSubtypeAndEquipSlot(slot)
          if #player:getEquipments(type) < #player:getAvailableEquipSlots(type) then
            local id = room:getCardsFromPileByRule(".|.|.|.|.|"..subtype_string_table[type], 1, "drawPile")[1]
            if id then
              room:useCard({
                from = player.id,
                tos = {{player.id}},
                card = Fk:getCardById(id),
              })
              break
            end
          end
        end
      end
    end
    end
    end
  end,
}
local yinrun_trigger = fk.CreateTriggerSkill{
  name = "#yinrun_trigger",
  mute = true,
  events = {fk.PreHpRecover, fk.CardUsing},
  can_trigger = function(self, event, target, player, data)
    if event == fk.PreHpRecover then
    return target == player and player:getMark("@@tey__yinrunhp") > 0
    elseif event == fk.CardUsing then
    return target == player and player:getMark("@@tey__yinrunstack") > 0 and data.card.type == Card.TypeBasic 
    end 
  end,
  on_cost = Util.TrueFunc,
  on_use = function(self, event, target, player, data)
    if event == fk.PreHpRecover then
    player:broadcastSkillInvoke("tey__yinrun", 4)
    player.room:setPlayerMark(player, "@@tey__yinrunhp", 0)
    data.num = data.num + 1
  elseif event == fk.CardUsing then
    player:broadcastSkillInvoke("tey__yinrun", 3)
    player.room:setPlayerMark(player, "@@tey__yinrunstack", 0)
    if data.tos then
    data.additionalEffect = (data.additionalEffect or 0) + 1
    end
    end
  end,
}
local tey__rongru = fk.CreateViewAsSkill{
  name = "tey__rongru",
  anim_type = "support",
  pattern = ".",
  interaction = function()
    local all_names = {"peach", "analeptic"}
    local names = U.getViewAsCardNames(Self, "tey__rongru", all_names, {})
    if #names > 0 then
      return U.CardNameBox { choices = names, all_choices = all_names }
    end
  end,
  card_filter = Util.FalseFunc,
  view_as = function(self, cards)
    if not self.interaction.data then return end
    local card = Fk:cloneCard(self.interaction.data)
    card.skillName = self.name
    return card
  end,
  before_use = function(self, player, use)
    local room = player.room
    local all_choices = {"WeaponSlot", "ArmorSlot", "DefensiveRideSlot", "OffensiveRideSlot", "TreasureSlot"}
    local subtypes = {Card.SubtypeWeapon, Card.SubtypeArmor, Card.SubtypeDefensiveRide, Card.SubtypeOffensiveRide, Card.SubtypeTreasure}
    local choices = {}
    for i = 1, 5, 1 do
      if #player:getAvailableEquipSlots(subtypes[i]) > 0 and player:getEquipment(subtypes[i]) then
        table.insert(choices, all_choices[i])
      end
    end
    local choice = room:askForChoice(player, choices, self.name, "#tey__rongru-choice", false, all_choices)
    room:abortPlayerArea(player, {choice})
    player:drawCards(1, self.name)
  end,
  enabled_at_play = function(self, player)
    local subtypes = {Card.SubtypeWeapon, Card.SubtypeArmor, Card.SubtypeDefensiveRide, Card.SubtypeOffensiveRide, Card.SubtypeTreasure}
    local x = 0
    for i = 1, 5, 1 do
      if #player:getAvailableEquipSlots(subtypes[i]) > 0 and player:getEquipment(subtypes[i]) then
        x = x + 1
      end
    end
    return x > 0
  end,
  enabled_at_response = function(self, player, response)
    local subtypes = {Card.SubtypeWeapon, Card.SubtypeArmor, Card.SubtypeDefensiveRide, Card.SubtypeOffensiveRide, Card.SubtypeTreasure}
    local x = 0
    for i = 1, 5, 1 do
      if #player:getAvailableEquipSlots(subtypes[i]) > 0 and player:getEquipment(subtypes[i]) then
        x = x + 1
      end
    end
    return not response and x > 0 and Fk.currentResponsePattern and 
    (Exppattern:Parse(Fk.currentResponsePattern):match(Fk:cloneCard("peach"))
     or Exppattern:Parse(Fk.currentResponsePattern):match(Fk:cloneCard("analeptic")))
  end,
}
tey__yinrun:addRelatedSkill(yinrun_trigger)
Sigewinne:addSkill(tey__yinrun)
Sigewinne:addSkill(tey__rongru)

Fk:loadTranslationTable{
  ["tey__Sigewinne"] = "希格雯", 
  ["#tey__Sigewinne"] = "柔柔露心",
  ["cv:tey__Sigewinne"] = "张安琪",
  ["illustrator:tey__Sigewinne"] = "怪三木",
  ["designer:tey__Sigewinne"] = "幽蝶化烬",

  ["tey__yinrun"] = "殷润",
  [":tey__yinrun"] = "锁定技，准备与结束阶段，你展示手牌。若两次点数差不大于你已损失体力值，你令一名角色下次使用基本牌多结算一次；"..
  "若两次牌名不完全相同，你令一名角色下次回复的体力值+1（均不叠加），背水：你随机为一个空置装备栏使用牌堆中的一张装备牌。",
  ["tey__rongru"] = "融濡",
  [":tey__rongru"] = "你可以废除一个有牌的装备栏并摸一张牌，视为使用【酒】或【桃】。",
  ["@tey__yinrunnum1-turn"] = "殷点",
  ["@$tey__yinruncard1-turn"] = "殷名",
  ["@tey__yinrunnum2-turn"] = "润点",
  ["@$tey__yinruncard2-turn"] = "润名",
  ["#tey__yinrunstack-choose"] = "殷润：选择一名角色，令其下次使用基本牌结算两次。",
  ["#tey__yinrunrecover-choose"] = "殷润：选择一名角色，令其下次回复体力值+1。",
  ["@@tey__yinrunstack"] = "基本结算+1",
  ["@@tey__yinrunhp"] = "回复体力+1",
  ["#yinrun_trigger"] = "殷润",

  ["$tey__yinrun1"] = "保养身体很重要，同样不能忽视的，是保养好自己的内心。",
  ["$tey__yinrun2"] = "没有哦，我没有在你背后贴贴纸。",
  ["$tey__yinrun3"] = "可爱的人值得最好的宝物。",
  ["$tey__yinrun4"] = "啊呀!哪里磕着碰着了吗?不舒服要随时叫我哟。",
  ["$tey__rongru1"] = "谨誓!精研医理。",
  ["$tey__rongru2"] = "医嘱:即刻注射。",
  ["~tey__Sigewinne"] = "好冷…好痛…",
}
local tey__fenzhi = fk.CreateTriggerSkill{
  name = "tey__fenzhi",
  anim_type = "drawcard",
  events = {fk.EventPhaseStart},
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(self) and player.phase == Player.Finish 
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
    local targets = {}
    for _, p in ipairs(room:getAlivePlayers()) do
      table.insert(targets, p.id)
    end
    local tos = room:askForChoosePlayers(player, targets, 2, 2, "#tey__fenzhi-cost", self.name, true)
    if #tos == 2 then
      self.cost_data = {tos = tos}
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local targets = table.simpleClone(self.cost_data.tos)
    room:sortPlayersByAction(targets)
    for _, p in ipairs(room:getAlivePlayers()) do
      room:setPlayerMark(p, "tey__fenzhi-to", 0)
    end
    for _, id in ipairs(targets) do
      local p2 = room:getPlayerById(id)
      room:setPlayerMark(p2, "tey__fenzhi-to", 1)
      if not p2:isAllNude() then
      local chosen = room:askForCardChosen(p2, p2, "hej", self.name)
      room:throwCard({chosen}, self.name, p2, p2)
      end
    end
    local target1, target2 = room:getPlayerById(self.cost_data.tos[1]), room:getPlayerById(self.cost_data.tos[2])
    if target1:getHandcardNum() > target2:getHandcardNum() then
      target2:drawCards(1, self.name)
      room:addPlayerMark(target2, "@tey__fenzhi", 1)
      if target2:getMark("@tey__fenzhi") == 3  then
        room:setPlayerMark(target2, "@tey__fenzhi", 0)
        room:recover({who = target1, num = 1, recoverBy = player, skillName = self.name})
      end
  elseif target2:getHandcardNum() > target1:getHandcardNum() then
      target1:drawCards(1, self.name)
      room:addPlayerMark(target1, "@tey__fenzhi", 1)
      if target1:getMark("@tey__fenzhi") == 3 then
      room:setPlayerMark(target1, "@tey__fenzhi", 0)
      room:recover({who = target2, num = 1, recoverBy = player, skillName = self.name})
      end
    end
    if target1.hp > target2.hp then
      target2:drawCards(1, self.name)
      room:addPlayerMark(target2, "@tey__fenzhi", 1)
      if target2:getMark("@tey__fenzhi") == 3  then
        room:setPlayerMark(target2, "@tey__fenzhi", 0)
        room:recover({who = target1, num = 1, recoverBy = player, skillName = self.name})
      end
  elseif target2.hp > target1.hp then
      target1:drawCards(1, self.name)
      room:addPlayerMark(target1, "@tey__fenzhi", 1)
      if target1:getMark("@tey__fenzhi") == 3 then
      room:setPlayerMark(target1, "@tey__fenzhi", 0)
      room:recover({who = target2, num = 1, recoverBy = player, skillName = self.name})
      end
    end
    if #target1:getCardIds(Player.Equip) > #target2:getCardIds(Player.Equip) then
      target2:drawCards(1, self.name)
      room:addPlayerMark(target2, "@tey__fenzhi", 1)
      if target2:getMark("@tey__fenzhi") == 3  then
        room:setPlayerMark(target2, "@tey__fenzhi", 0)
        room:recover({who = target1, num = 1, recoverBy = player, skillName = self.name})
      end
  elseif #target2:getCardIds(Player.Equip) > #target1:getCardIds(Player.Equip) then
      target1:drawCards(1, self.name)
      room:addPlayerMark(target1, "@tey__fenzhi", 1)
      if target1:getMark("@tey__fenzhi") == 3 then
      room:setPlayerMark(target1, "@tey__fenzhi", 0)
      room:recover({who = target2, num = 1, recoverBy = player, skillName = self.name})
      end
    end
     if target1:getHandcardNum() == target2:getHandcardNum() then
      if target2.hp == target1.hp or #target1:getCardIds(Player.Equip) == #target2:getCardIds(Player.Equip) then
      room:setPlayerMark(target1, "@@tey__fenzhi_nil", 1)
      room:setPlayerMark(target2, "@@tey__fenzhi_nil", 1)
      end
     end
     if target2.hp == target1.hp then
      if #target1:getCardIds(Player.Equip) == #target2:getCardIds(Player.Equip) then
      room:setPlayerMark(target1, "@@tey__fenzhi_nil", 1)
      room:setPlayerMark(target2, "@@tey__fenzhi_nil", 1)
      end
     end
  end,

  refresh_events = {fk.TurnStart},
  can_refresh = function(self, event, target, player, data)
    if not player:hasSkill(self,true) then return false end
    return target == player
  end,
  on_refresh = function(self, event, target, player, data)
    for _, p in ipairs(player.room:getAlivePlayers()) do
      player.room:setPlayerMark(p, "@@tey__fenzhi_nil", 0)
    end
  end,

  on_lose = function (self, player, is_death)
    for _, p in ipairs(player.room:getAlivePlayers()) do
      player.room:setPlayerMark(p, "@@tey__fenzhi_nil", 0)
      player.room:setPlayerMark(p, "tey__fenzhi-to", 0)
      player.room:setPlayerMark(p, "@tey__fenzhi", 0)
    end
  end,
}
local tey__fenzhi_delay = fk.CreateTriggerSkill{
  name = "#tey__fenzhi_delay",
  mute = true,
  frequency = Skill.Compulsory,
  events = {fk.DamageInflicted},
  can_trigger = function(self, event, target, player, data)
    return target:getMark("@@tey__fenzhi_nil") > 0 and
    data.card and data.card.trueName == "slash" and data.card.color == Card.Black
  end,
  on_use = function(self, event, target, player, data)
    target:broadcastSkillInvoke("tey__fenzhi")
    return true
  end,
}
local tey__jiuji = fk.CreateTriggerSkill{
  name = "tey__jiuji",
  mute = true,
  frequency = Skill.Wake,
  events = {fk.Death},
  can_trigger = function(self, event, target, player, data)
    if player:hasSkill(self) and player:usedSkillTimes(self.name, Player.HistoryGame) == 0 then
      return target:getMark("tey__fenzhi-to") > 0 and player:getMark("tey__fenzhi-to") > 0 and data.damage and data.damage.from and
      not data.damage.from.dead
    end
  end,
  can_wake = function(self, event, target, player, data)
    return target:getMark("tey__fenzhi-to") > 0 and player:getMark("tey__fenzhi-to") > 0
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:notifySkillInvoked(player, self.name, "big")
    player:broadcastSkillInvoke(self.name, math.random(2))
    room:setPlayerMark(data.damage.from, "@@tey__jiuji_revenge", 1)
  end,
}
local tey__jiuji_delay = fk.CreateTriggerSkill{
  name = "#tey__jiuji_delay",
  mute = true,
  events = {fk.DamageCaused},
  can_trigger = function(self, event, target, player, data)
    return player == target and data.to:getMark("@@tey__jiuji_revenge") > 0 and player:hasSkill(self, true)
  end,
  on_cost = Util.TrueFunc,
  on_use = function(self, event, target, player, data)
    if player:hasSkill("tey__jiuji", true) then
      player:broadcastSkillInvoke("tey__jiuji", 3)
    end
    data.damage = data.damage + 1
  end,
}
local tey__jiuji_targetmod = fk.CreateTargetModSkill{
  name = "#tey__jiuji_targetmod",
  bypass_distances =  function(self, player, skill, card, target)
    return player:hasSkill("tey__jiuji") and target:getMark("@@tey__jiuji_revenge") > 0
  end,
}

tey__fenzhi:addRelatedSkill(tey__fenzhi_delay)
tey__jiuji:addRelatedSkill(tey__jiuji_delay)
tey__jiuji:addRelatedSkill(tey__jiuji_targetmod)
Chasca:addSkill(tey__fenzhi)
Chasca:addSkill(tey__jiuji)

Fk:loadTranslationTable{
  ["tey__Chasca"] = "恰斯卡", 
  ["#tey__Chasca"] = "巡宇翦定",
  ["cv:tey__Chasca"] = "张若瑜",
  ["illustrator:tey__Chasca"] = "酥脆球球",
  ["designer:tey__Chasca"] = "幽蝶化烬",

  ["tey__fenzhi"] = "纷止",
  [":tey__fenzhi"] = "结束阶段，你可以选择两名角色，其各弃置其区域内一张牌。<br>若如此做，两名角色(手牌数，体力值，装备区牌数)每有一项不同，较小的角色摸一张牌；<br>"..
  "其中一名角色因本技能累计摸第三X张牌后（X为任意正整数），另一名角色回复1点体力；<br>最后若至少两项相等，防止这些角色受到黑色【杀】的伤害直至你回合开始。",
  ["tey__jiuji"] = "鹫寂",
  [":tey__jiuji"] = "觉醒技，其他角色死亡时，若上次“纷止”的目标为你与其，你对杀死其的角色使用牌无距离限制且造成的伤害+1。",
  ["#tey__fenzhi-cost"] = "纷止：你可以令选择名角色，各弃置区域内一张牌后比较条件大小摸牌",
  ["@tey__fenzhi"] = "纷止",
  ["#tey__fenzhi_delay"] = "纷止",
  ["@@tey__fenzhi_nil"] = "不受黑杀伤害",
  ["@@tey__jiuji_revenge"] = "鹫寂",
  ["#tey__jiuji_delay"] = "鹫寂",

  ["$tey__fenzhi1"] = "分赃不均是起矛盾的大头。好在我用不上，你拿着就好。",
  ["$tey__fenzhi2"] = "想要我为你调停什么?部族纷争?还是一场大战?",
  ["$tey__jiuji1"] = "葵可她…希望我成为「英雄」,所以我不能为她停下脚步，不能让自己变得软弱…",
  ["$tey__jiuji2"] = "既然忘不掉这份恐惧…那就试着记住它，然后…「超越」它吧。",
  ["$tey__jiuji3"] = "全弹…发射！",
  ["~tey__Chasca"] = "我也…坠落了吗…",
} 

Fk:loadTranslationTable{
  ["tey__Nirou"] = "妮露", 
  ["#tey__Nirou"] = "莲光落舞筵",
  ["cv:tey__Nirou"] = "紫苏九月",
  ["illustrator:tey__Nirou"] = "透明Tomei",
  ["designer:tey__Nirou"] = "幽蝶化烬",

  ["tey__yaomei"] = "邀袂",
  [":tey__yaomei"] = "锁定技，你使用牌无①距离②次数③对象限制。你回合内使用牌后摸剩余项数张牌并移除一项。所有项均移去后，你翻转所有手牌，然后你下次造成的属性伤害+1。",
  ["tey__suyue"] = "愫阅",
  [":tey__suyue"] = "轮次结束后，所有角色可以同时展示一张牌并令你获得之，然后若你能选择一名为这些牌合法目标的角色，你复原〖邀袂〗等量项。",

  ["$tey__yaomei1"] = "",
  ["$tey__yaomei2"] = "",
  ["$tey__suyue1"] = "",
  ["$tey__suyue2"] = "",
  ["~tey__Nirou"] = "…",
}

local tey__mengpian = fk.CreateTriggerSkill{
  name = "tey__mengpian",
  anim_type = "offensive",
  frequency = Skill.Compulsory,
  events = {fk.CardUsing},
  can_trigger = function(self, event, target, player, data)
    if target == player and player:hasSkill(self) then
    return (data.card:isCommonTrick() and not table.contains(player:getTableMark("@$tey__mengpian"), data.card.trueName))
    or player:getMark("@@tey__mengpian-turn") > 0
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local mark = player:getTableMark("@$tey__mengpian")
    if player:getMark("@@tey__mengpian-turn") > 0 then
    room:setPlayerMark(player, "@@tey__mengpian-turn", 0)
    local targets = TargetGroup:getRealTargets(data.tos)
    if #targets == 1 and not room:getPlayerById(targets[1]).dead then
      local choice = room:askForChoice(player, {"addshield","draweach"}, self.name,
      "#tey_mengpian-choose")
      if choice == "addshield" then
        room:changeShield(room:getPlayerById(targets[1]), 1)
      else
        player:drawCards(1, self.name)
        if not room:getPlayerById(targets[1]).dead and player.id ~= targets[1] then
        room:getPlayerById(targets[1]):drawCards(1, self.name)
        end
      end
    end
  elseif data.card:isCommonTrick() and not table.contains(player:getTableMark("@$tey__mengpian"), data.card.trueName) then
    table.insert(mark, data.card.trueName)
    room:setPlayerMark(player, "@$tey__mengpian", #mark > 0 and mark or 0)
    local name
    room.logic:getEventsByRule(GameEvent.UseCard, 1, function (e)
      if e.id < player.room.logic:getCurrentEvent():findParent(GameEvent.UseCard, true).id then
      local use = e.data[1]
      if use.from == player.id then
        name = use.card.name
        return true
      end
      end
    end, 1)
    if name ~= nil and #name > 0 then
    player:addCardUseHistory(name, -1)
    end
    room:setPlayerMark(player, "@@tey__mengpian-turn", 1)
    end
  end,

  on_lose = function (self, player, is_death)
    local room = player.room
    room:setPlayerMark(player, "@$tey__mengpian", 0)
    room:setPlayerMark(player, "@@tey__mengpian-turn", 0)
  end,
}
Layla:addSkill(tey__mengpian)
local tey__diesuan = fk.CreateTriggerSkill{
  name = "tey__diesuan",
  anim_type = "drawcard",
  events = {fk.CardUseFinished},
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(self)
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local draw = player:drawCards(1, self.name)
    local card = Fk:getCardById(draw[1])
    local suc, dat = room:askForUseActiveSkill(player, "tey__diesuan_active", "#tey__diesuan_active", false,
    {use_num = data.card.number, draw_num = card.number})
      if suc then
        local cards = dat.cards
        local choice = dat.interaction
        local nuilify = false
        if choice == "cancel" or player:getMark("@tey__diesuan") == choice then
          nuilify = true
        end
        room:setPlayerMark(player, "@tey__diesuan", choice == "cancel" and 0 or choice)
        if #cards > 0 then
          room:throwCard(cards, self.name, player, player)
        end
        if nuilify then
          room:setPlayerMark(player, "tey__diesuan_nuil-turn", 1)
        end
      end
  end,

  on_lose = function (self, player, is_death)
    local room = player.room
    room:setPlayerMark(player, "@tey__diesuan", 0)
  end,
}
local tey__diesuan_invalidity = fk.CreateInvaliditySkill {
  name = "#tey__diesuan_invalidity",
  invalidity_func = function(self, from, skill)
    return skill == tey__diesuan and from:getMark("tey__diesuan_nuil-turn") > 0
  end
}
local tey__diesuan_active = fk.CreateActiveSkill{
  name = "tey__diesuan_active",
  prompt = "#tey__diesuan_active",
  interaction = function(self)
    local names = {"tey__diesuan_use_num", "tey__diesuan_draw_num", "cancel"}
    return UI.ComboBox {choices = names}
  end,
  card_filter = function(self, to_select, selected)
    local num = 0
    for _, id in ipairs(selected) do
      num = num + Fk:getCardById(id).number
    end
    if self.interaction.data == "tey__diesuan_use_num" then
      return num + Fk:getCardById(to_select).number <= self.use_num
    elseif self.interaction.data == "tey__diesuan_draw_num" then
      return num + Fk:getCardById(to_select).number <= self.draw_num
    elseif self.interaction.data == "cancel" then
      return false
    end
  end,
  feasible = function (self, selected, selected_cards)
    local x = 0
    for _, id in ipairs(selected_cards) do
      x = x + Fk:getCardById(id).number
    end
    if self.interaction.data == "tey__diesuan_use_num" then
      return x == self.use_num
    elseif self.interaction.data == "tey__diesuan_draw_num" then
      return x == self.draw_num
    elseif self.interaction.data == "cancel" then
      return true
    end
  end,
}
Fk:addSkill(tey__diesuan_active)
tey__diesuan:addRelatedSkill(tey__diesuan_invalidity)
Layla:addSkill(tey__diesuan)

Fk:loadTranslationTable{
  ["tey__Layla"] = "莱伊拉", 
  ["#tey__Layla"] = "绮思晚星",
  ["cv:tey__Layla"] = "侯小菲",
  ["illustrator:tey__Layla"] = "Skym空明",
  ["designer:tey__Layla"] = "幽蝶化烬",

  ["tey__mengpian"] = "梦翩",
  [":tey__mengpian"] = "锁定技，每牌名限一次，你使用普通锦囊牌时，你使用的上张牌不计入次数限制；你本回合使用下张牌时，与唯一目标各摸一张牌（若其为你，改为你摸一张牌）或令其获得1点护甲。",
  ["tey__diesuan"] = "叠算",
  [":tey__diesuan"] = "你使用牌后，你可以摸一张牌，然后你可以选择一项：弃置任意张点数和等于使用牌的牌；或弃置任意张点数和等于获得牌的牌。"..
  "若与上次发动的选择相同或不选择，本回合本技能失效。",

  ["@$tey__mengpian"] = "梦翩",
  ["@@tey__mengpian-turn"] = "梦翩 目标叠甲",
  ["#tey_mengpian-choose"] = "梦翩：请选择令目标执行的一项：",
  ["addshield"] = "令其获得护甲",
  ["draweach"] = "各摸一张牌",
  ["@tey__diesuan"] = "叠算",
  ["tey__diesuan_active"] = "叠算",
  ["tey__diesuan_use_num"] = "用牌点数",
  ["tey__diesuan_draw_num"] = "摸牌点数",
  ["#tey__diesuan_active"] = "叠算：请选择任意张点数和符合选项所示的牌弃置，若连续选择同一项或取消，本回合叠算失效。",

  ["$tey__mengpian1"] = "星辰，为我降下。",
  ["$tey__mengpian2"] = "极寒，任我驱使。",
  ["$tey__diesuan1"] = "就算我们不抬头仰望，星空，也永远注视着我们。",
  ["$tey__diesuan2"] = "莱依拉啊莱依拉，你还要更勤奋。",
  ["~tey__Layla"] = "永恒的睡眠…",
} 

local tey__tuoyi = fk.CreateActiveSkill{
  name = "tey__tuoyi",
  mute = true,
  anim_type = "offensive",
  card_num = 3,
  target_num = 0,
  interaction = function(self)
    return UI.ComboBox {choices = {"ready_skill_reset", "ready_skill_check"}}
  end,
  can_use = function(self, player)
    return player:usedSkillTimes("#tey__tuoyi_true", Player.HistoryGame) > 0 and player:usedSkillTimes("#tey__tuoyi_true", Player.HistoryRound) == 0
  end,
  card_filter = function(self, to_select, selected)
    if self.interaction.data == "ready_skill_reset" then
    return #selected < 3 and not Self:prohibitDiscard(Fk:getCardById(to_select))
    elseif self.interaction.data == "ready_skill_check" then
    return false
    end
  end,
  target_filter = Util.FalseFunc,
  on_use = function(self, room, effect)
    local player = room:getPlayerById(effect.from)
    player:broadcastSkillInvoke(self.name, math.random(2))
    room:throwCard(effect.cards, self.name, player, player)
    if self.interaction.data == "ready_skill_reset" then
    player:setSkillUseHistory("#tey__tuoyi_true", 0, Player.HistoryGame)
    player:setSkillUseHistory("#tey__tuoyi_true", 0, Player.HistoryRound)
    room:setPlayerMark(player, "@@tey__tuoyi_readying", 0)
    end
    if player:hasSkill("tey__keqin")then
      tey__keqin_renew:doCost(event, target, player, data)
    end
  end,
}

local tey__tuoyi_true = fk.CreateTriggerSkill{
  name = "#tey__tuoyi_true",
  anim_type = "offensive",
  events = {fk.TurnEnd},
  can_trigger = function(self, event, target, player, data)
    if player:hasSkill(self) and target ~= player and player:getMark("@@tey__tuoyi_readying") == 0 then
      local x = 0
      if target:getMark("tey__tuoyi1-turn") == 1 then
        x = x + 1
      end
      if target:getMark("tey__tuoyi2-turn") == 1 then
        x = x + 1
      end
      if target:getMark("tey__tuoyi3-turn") == 1 then
        x = x + 1
      end
      return x > 0
    end
  end,
  on_cost = function(self, event, target, player, data)
    return player.room:askForSkillInvoke(player, self.name, nil, "#tey__tuoyi_trues:")
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:setPlayerMark(player, "@@tey__tuoyi_readying", 1)
    local x = 0
      if target:getMark("tey__tuoyi1-turn") == 1 then
        x = x + 1
      end
      if target:getMark("tey__tuoyi2-turn") == 1 then
        x = x + 1
      end
      if target:getMark("tey__tuoyi3-turn") == 1 then
        x = x + 1
      end
    for i = 1, x, 1 do
      if target.dead then break end
      local choice = room:askForChoice(player, {"cancel","tuoyi_continue"}, "tey_tuoyi_true",
        "#tey_tuoyi-choose:::" .. i .. ":" .. x)
      if choice == "cancel" then
        break
      else
      player:broadcastSkillInvoke("tey__tuoyi", math.random(3,5))
      if target:isNude() then
        player:drawCards(1, self.name)
        if not target.dead then
        room:useVirtualCard("thunder__slash", nil, player, target, self.name)
        end
      else
        local chosen = room:askForCardChosen(player, target, "he", self.name)
        if chosen then
          local slash = Fk:cloneCard("thunder__slash")
          slash.skillName = self.name
          slash:addSubcard(chosen)
          if player:canUseTo(slash, target, { bypass_times = true, bypass_distances= true }) then
          room:useCard{
            from = player.id,
            card = slash,
            tos = { { target.id } },
            extraUse = true,
          }
          end
        end
      end
      end
  end
end,

refresh_events = {fk.AfterDrawPileShuffle, fk.RoundEnd},
can_refresh = function(self, event, target, player, data)
  local room = player.room
  if event == fk.AfterDrawPileShuffle then
  return player:getMark("@@tey__tuoyi_readying") > 0
  elseif event == fk.RoundEnd then
  return player:getMark("@@tey__tuoyi_readying") > 0
  and #room.logic:getEventsOfScope(GameEvent.UseCard, 1, function (e)
    local use = e.data[1]
    return use.from == player.id
    and use.card.color == Card.Black
    and use.card.suit == Card.Spade
    and use.card.type == Card.TypeTrick
  end, Player.HistoryRound) == 0
  and #room.logic:getEventsOfScope(GameEvent.UseCard, 1, function (e)
    local use = e.data[1]
    return use.from == player.id
    and use.card.color == Card.Black
    and #TargetGroup:getRealTargets(use.tos) > 1
  end, Player.HistoryRound) == 0
  and #room.logic:getEventsOfScope(GameEvent.UseCard, 1, function (e)
    local use = e.data[1]
    return use.from == player.id
    and use.card.color == Card.Black
    and use.card.is_damage_card
  end, Player.HistoryRound) == 0
  end
end,
on_refresh = function(self, event, target, player, data)
  local room = player.room
  room:setPlayerMark(player, "@@tey__tuoyi_readying", 0)
  player:setSkillUseHistory("#tey__tuoyi_true", 0, Player.HistoryGame)
  player:setSkillUseHistory("#tey__tuoyi_true", 0, Player.HistoryRound)
end,

on_lose = function (self, player, is_death)
  local room = player.room
    room:setPlayerMark(player, "@@tey__tuoyi_readying", 0)
    player:setSkillUseHistory("#tey__tuoyi_true", 0, Player.HistoryGame)
    player:setSkillUseHistory("#tey__tuoyi_true", 0, Player.HistoryRound)
end,
}

local tey__tuoyi_record = fk.CreateTriggerSkill{
  name = "#tey__tuoyi_record",

  refresh_events = {fk.CardUseFinished},
  can_refresh = function(self, event, target, player, data)
    return target == player and data.card.color == Card.Black
  end,
  on_refresh = function(self, event, target, player, data)
    if player:getMark("tey__tuoyi1-turn") == 0 and data.card.suit == Card.Spade
    and data.card.type == Card.TypeTrick then
      player.room:setPlayerMark(player, "tey__tuoyi1-turn", 1)
    end
    if player:getMark("tey__tuoyi2-turn") == 0 and #TargetGroup:getRealTargets(data.tos) > 1 then
      player.room:setPlayerMark(player, "tey__tuoyi2-turn", 1)
    end
    if player:getMark("tey__tuoyi3-turn") == 0 and data.card.is_damage_card
    and data.damageDealt then
      player.room:setPlayerMark(player, "tey__tuoyi3-turn", 1)
    end
  end,

  on_acquire = function (self, player, is_start)
    if not is_start and player.phase ~= Player.NotActive then
      local room = player.room
     if #room.logic:getEventsOfScope(GameEvent.UseCard, 1, function (e)
        local use = e.data[1]
        return use.from == player.id
        and use.card.color == Card.Black
        and use.card.suit == Card.Spade
        and use.card.type == Card.TypeTrick
      end, Player.HistoryTurn) > 0 then
      player.room:setPlayerMark(player, "tey__tuoyi1-turn", 1)
     end
     if #room.logic:getEventsOfScope(GameEvent.UseCard, 1, function (e)
        local use = e.data[1]
        return use.from == player.id
        and use.card.color == Card.Black
        and #TargetGroup:getRealTargets(use.tos) > 1
      end, Player.HistoryTurn) > 0 then
      player.room:setPlayerMark(player, "tey__tuoyi2-turn", 1)
     end
     if #room.logic:getEventsOfScope(GameEvent.UseCard, 1, function (e)
        local use = e.data[1]
        return use.from == player.id
        and use.card.color == Card.Black
        and use.card.is_damage_card
        and use.damageDealt
      end, Player.HistoryTurn) > 0 then
      player.room:setPlayerMark(player, "tey__tuoyi3-turn", 1)
     end
    end
  end,
}

tey__tuoyi:addRelatedSkill(tey__tuoyi_record)
tey__tuoyi:addRelatedSkill(tey__tuoyi_true)
Cyno:addSkill(tey__tuoyi)

Fk:loadTranslationTable{
  ["tey__Cyno"] = "赛诺", 
  ["#tey__Cyno"] = "沓峰寂观",
  ["cv:tey__Cyno"] = "李轻扬",
  ["illustrator:tey__Cyno"] = "乱乱&Mizuyo",
  ["designer:tey__Cyno"] = "幽蝶化烬",

  ["tey__tuoyi"] = "柝仪",
  [":tey__tuoyi"] = "<a href='ready_skill_href'>蓄势技</a>，其他角色的回合结束时，你可以执行至多X次：<br>1.若其有牌，将其一张牌当雷【杀】对其使用；<br>"..
  "2.若其没有牌，你摸一张牌，视为对其使用雷【杀】。<br>"..
  "X为其本回合使用的黑色牌包含的项数：♠锦囊牌；目标数大于1；伤害类牌（且造成伤害）<br>"..
  "你未使用过上述黑色牌的轮次结束后，重置本技能。",
  ["@@tey__tuoyi_readying"] = "柝仪 蓄势",
  ["#tey__tuoyi_trues"] = "是否发动 柝仪，对当前回合角色使用雷【杀】？",
  ["#tey__tuoyi_record"] = "柝仪",
  ["tey__tuoyi_trues"] = "柝仪",
  ["#tey_tuoyi_true"] = "柝仪",
  ["#tey__tuoyi_true"] = "柝仪",
  ["tey_tuoyi_true"] = "柝仪",
  ["#tey_tuoyi-choose"] = "柝仪：选择一项执行（%arg/%arg2）",
  ["tuoyi_continue"] = "继续用杀",

  ["$tey__tuoyi1"] = "运势会左右某一场对决的胜负，但不会一直影响下去。",
  ["$tey__tuoyi2"] = "偶尔我也想缓解一下气氛，但我其实分不太清什么笑话能够引人发笑。",
  ["$tey__tuoyi3"] = "以此身…肃正万象!",
  ["$tey__tuoyi4"] = "判决，如期降临。",
  ["$tey__tuoyi5"] = "称量，你的罪孽。",
  ["~tey__Cyno"] = "覆灭…新生…终而复始。",
} 
local xunmei_derivecards = {{"archery_attack", Card.Spade, 12}}
local tey__xunmei = fk.CreateTriggerSkill{
  name = "tey__xunmei",
  anim_type = "offensive",
  events = {fk.GameStart,fk.AfterCardsMove},
  frequency = Skill.Compulsory,
  can_trigger = function(self, event, target, player, data)
    if not player:hasSkill(self) then return false end
    if event == fk.GameStart then
      return true
    elseif event == fk.AfterCardsMove then
      local room = player.room
      local ids = {}
        for _, move in ipairs(data) do
         if move.toArea == Card.DiscardPile then
          for _, info in ipairs(move.moveInfo) do
            if Fk:getCardById(info.cardId):getMark("@@tey__xunmei") > 0 then
              table.insertIfNeed(ids, info.cardId)
            end
          end
         end
       end
       if #ids > 0 then
        return true
      end
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    if event == fk.GameStart then
      local cards = {}
      table.insertTable(cards, room:getCardsFromPileByRule("indulgence|.|.|.|.|."))
      table.insertTable(cards, room:getCardsFromPileByRule("eight_diagram|.|.|.|.|."))
      table.insertTable(cards, room:getCardsFromPileByRule("analeptic|.|.|.|.|."))
      if #cards > 0 then
        for _, id in ipairs(cards) do
        room:setCardMark(Fk:getCardById(id), "@@tey__xunmei", 1)
      end
        room:moveCardTo(cards, Card.PlayerHand, player, fk.ReasonPrey, self.name, nil, true, player.id)
      end
    elseif event == fk.AfterCardsMove then
      local choices1 = {"tey__xunmei_clear"}
      local choices2 = {"tey__xunmei_draw"}
      local cards = table.filter(U.prepareDeriveCards(room, xunmei_derivecards, "tey__xunmei_derivecards"), function (id)
        return room:getCardArea(id) == Card.Void
      end)
      for _, id in ipairs(cards) do
      room:setCardMark(Fk:getCardById(id), "@@tey__xunmei", 1)
      end
      if #cards > 0 then table.insert(choices2, "tey__xunmei_arrow") end
      local tar = table.filter(room.alive_players, function(p) return p.shield == 0 end)
      if #tar > 0 then table.insert(choices2, "tey__xunmei_shield") end
      if #choices2 >= 2 then table.insert(choices1, "tey__xunmei_another") end
      local choice1 = room:askForChoice(player, choices1, self.name, "#tey__xunmei-invoke:", false,{"tey__xunmei_clear","tey__xunmei_another"})
      if choice1 == "tey__xunmei_clear" then
        for _, move in ipairs(data) do
          if move.toArea == Card.DiscardPile then
           for _, info in ipairs(move.moveInfo) do
            room:setCardMark(Fk:getCardById(info.cardId), "@@tey__xunmei", 0)
           end
          end
        end
      elseif choice1 == "tey__xunmei_another" then
        local x = 2
        for i = 1, x ,1 do
        local choice2 = room:askForChoice(player, choices2, self.name, "#tey_xunmei-choose:::" .. i .. ":" .. x,
        false,{"tey__xunmei_draw","tey__xunmei_arrow","tey__xunmei_shield"})
        table.removeOne(choices2, choice2)
        if choice2 == "tey__xunmei_draw" then
          local to1 = room:askForChoosePlayers(player, table.map(room.alive_players, Util.IdMapper),
           1, 1, "#tey__xunmei1-choose", self.name, false)
           local to1s = room:getPlayerById(to1[1])
           to1s:drawCards(2, self.name)
        elseif choice2 == "tey__xunmei_arrow" then
          local to2 = room:askForChoosePlayers(player, table.map(room.alive_players, Util.IdMapper),
          1, 1, "#tey__xunmei2-choose", self.name, false)
          if #to2 > 0 then
            room:moveCards({
              ids = table.random(cards, 1),
              to = to2[1],
              toArea = Card.PlayerHand,
              moveReason = fk.ReasonGive,
              proposer = player.id,
              skillName = self.name,
              moveVisible = true,
            })
          end
        elseif choice2 == "tey__xunmei_shield" then
          if #tar > 0 then
          local to3 = room:askForChoosePlayers(player, table.map(tar, Util.IdMapper),
          1, 1, "#tey__xunmei3-choose", self.name, false)
          if #to3 > 0 then
            local to3s = room:getPlayerById(to3[1])
            room:changeShield(to3s, 1)
          end
          end
        end
       end
      end
    end
  end,
}

local tey__shengqiang = fk.CreateTriggerSkill{
  name = "tey__shengqiang",
  anim_type = "control",
  events = {fk.FinishJudge},
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(self) and data.card.suit ~= Card.Heart
    and table.contains({"eight_diagram", "#eight_diagram_skill", "indulgence"}, data.reason)
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
    if event == fk.FinishJudge then
    local card = room:askForResponse(player, self.name, ".|.|.|hand|.|.", "#tey_shengqiang-response", true)
    if card then
      room:responseCard{from = player.id, card = card}
      return true
    end
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local e = room.logic:getCurrentEvent():findParent(GameEvent.SkillEffect)
    if e then
      room.logic:getCurrentEvent():addExitFunc(function()
        e:shutdown()
      end)
      local parent = e.parent
      if parent and parent.event == GameEvent.CardEffect then
        local effect = parent.data[1]
        if effect.card.sub_type == Card.SubtypeDelayedTrick and room:getCardArea(effect.card:getEffectiveId()) == Card.Processing
          and not target.dead and not target:hasDelayedTrick(effect.card.name) and not table.contains(target.sealedSlots, Player.JudgeSlot)
          then
          local card = effect.card
          if card:isVirtual() then
            card = Fk:cloneCard(card.name)
            card:addSubcards(effect.card.subcards)
            card.skillNames = effect.card.skillNames
            target:addVirtualEquip(card)
          end
          room:moveCardTo(card, Player.Judge, target, fk.ReasonJustMove, self.name)
        end
      end
    end
      room:moveCardTo(data.card, Card.PlayerHand, player, fk.ReasonPrey, self.name)
  end,
}
Navia:addSkill(tey__xunmei)
Navia:addSkill(tey__shengqiang)

Fk:loadTranslationTable{
  ["tey__Navia"] = "娜维娅", 
  ["#tey__Navia"] = "明花蔓舵",
  ["cv:tey__Navia"] = "小敢",
  ["illustrator:tey__Navia"] = "Minty0",
  ["designer:tey__Navia"] = "幽蝶化烬",

  --["tey__xunmei"] = "寻玫",
  --[":tey__xunmei"] = "锁定技，游戏开始时，你获得【乐不思蜀】【八卦阵】【酒】各一张并标记之。标记牌进入弃牌堆后，你清除此牌标记或选择两项："..
  --"令一名角色获得游戏外唯一一张已标记的【万箭齐发】；令一名角色摸两张牌；令一名没有护甲的角色获得1点护甲。",
  --["tey__shengqiang"] = "盛蔷",
  --[":tey__shengqiang"] = "锁定技，一名角色非♥的【乐不思蜀】或【八卦阵】判定牌生效时，你终止判定，获得判定牌并标记之或于本阶段结束时使用之，"..
  --"然后可以令其将手牌摸至或打出至与你相等（至多摸五张）。",
  ["tey__xunmei"] = "寻玫",
  [":tey__xunmei"] = "出牌阶段限一次，你可以令一名角色选择一项：将两张牌置于牌堆顶，视为使用【五谷丰登】；令你摸两张牌，其视为对你使用【万箭齐发】。"..
  "背水：获得1点护甲，你将一张【乐不思蜀】置于判定区。",
  ["tey__shengqiang"] = "盛蔷",
  [":tey__shengqiang"] = "一名角色非♥的【乐不思蜀】或【八卦阵】判定牌生效时，你可以打出一张手牌以终止判定，然后获得此判定牌。",
  ["@@tey__xunmei"] = "寻玫",
  ["#tey__xunmei-invoke"] = "寻玫：选择清除此牌标记或另外的两项",
  ["tey__xunmei_clear"] = "清除此牌标记",
  ["tey__xunmei_another"] = "选择两项（万箭/摸牌/叠甲）",
  ["#tey_xunmei-choose"] = "寻玫：选择一项执行（%arg/%arg2）",
  ["tey__xunmei_draw"] = "令一名角色摸两张牌",
  ["tey__xunmei_arrow"] = "令一名角色获得游戏外万箭齐发",
  ["tey__xunmei_shield"] = "令一名没有护甲的角色获得1点护甲",
  --["tey__shengqiang_prey"] = "获得判定牌",
  --["tey__shengqiang_use"] = "本阶段结束后使用判定牌",
  --["tey__shengqiang_equal"] = "令其摸牌或打出手牌至与你相等",
  ["#tey__xunmei1-choose"] = "寻玫：令一名角色摸两张牌。",
  ["#tey__xunmei2-choose"] = "寻玫：令一名角色获得游戏外一张万箭齐发。",
  ["#tey__xunmei3-choose"] = "寻玫：令一名没有护甲的角色获得1点护甲。",
  ["#tey_shengqiang-response"] = "盛蔷：是否打出一张手牌以终止判定？",
  --["#tey__shengqiang-invoke"] = "盛蔷：你已终止%dest 的判定，请对判定牌执行一项！",
 -- ["#tey__shengqiang-afteruse"] = "盛蔷：请使用本阶段任意张被本技能标记的判定牌，或取消。",

  ["$tey__xunmei1"] = "开火!虽然是岩元素啦。",
  ["$tey__xunmei2"] = "玫瑰礼花!刺玫会特别定制版。",
  ["$tey__xunmei3"] = "是…伞弹枪?",
  ["$tey__xunmei4"] = "猜我还有几颗子弹?",
  ["$tey__shengqiang1"] = "哎呀!刚才看到闪电就该捂住耳朵的!",
  ["$tey__shengqiang2"] = "晚间新闻播报:「今天的刺玫会会长也和她的好搭档度过了完美的一天。」真棒!",
  ["$tey__shengqiang3"] = "刺玫会的标志是母亲设计的，我非常喜欢。你看，轮廓像颗心脏一样呢。",
  ["$tey__shengqiang4"] = "早上好!想好今天要做什么了吗?没想好的话，要不要跟我来?",
  ["~tey__Navia"] = "就当是…回家了…",
} 

local tey__chengjing_chasingNearSkill = fk.CreateActiveSkill{
  name = "tey__chengjing_chasing_near_skill",
  prompt = "#chasing_near_skill",
  target_num = 1,
  mod_target_filter = function(self, to_select, selected, user, card, distance_limited)
    return to_select ~= user and not Fk:currentRoom():getPlayerById(to_select):isAllNude()
  end,
  target_filter = Util.TargetFilter,
  on_effect = function(self, room, effect)
    local from = room:getPlayerById(effect.from)
    local to = room:getPlayerById(effect.to)
    if to:isAllNude() then return end
    local id1 = room:askForCardChosen(from, to, "hej", self.name)
      room:throwCard({id1}, self.name, to, from)
    if to:isAllNude() then return end
    local id2 = room:askForCardChosen(from, to, "hej", self.name)
      room:obtainCard(from, id2, false, fk.ReasonPrey)
  end
}
tey__chengjing_chasingNearSkill.cardSkill = true
Fk:addSkill(tey__chengjing_chasingNearSkill)

local tey__chengjing_analepticSkill = fk.CreateActiveSkill{
  name = "tey__chengjing_analeptic_skill",
  prompt = "#analeptic_skill",
  target_num = 1,
  mod_target_filter = Util.TrueFunc,
  can_use = function(self, player, card)
    return not player:isProhibited(player, card)
  end,
  on_effect = function(_, room, effect)
    local to = room:getPlayerById(effect.to)
      room:recover({
        who = to,
        num = 1,
        recoverBy = room:getPlayerById(effect.from),
        card = effect.card,
      })
      to.drank = to.drank + 1 + ((effect.extra_data or {}).additionalDrank or 0)
      room:broadcastProperty(to, "drank")
  end
}
tey__chengjing_analepticSkill.cardSkill = true
Fk:addSkill(tey__chengjing_analepticSkill)

local tey__chengjing_tey__drowningSkill = fk.CreateActiveSkill{
  name = "tey__chengjing_tey__drowning_skill",
  prompt = "#tey__drowning_skill",
  can_use = Util.CanUse,
  min_target_num = 1,
  max_target_num = 2,
  mod_target_filter = Util.TrueFunc,
  target_filter = Util.TargetFilter,
  on_effect = function(self, room, effect)
    local from = room:getPlayerById(effect.from)
    local to = room:getPlayerById(effect.to)
    room:damage({
      from = from,
      to = to,
      card = effect.card,
      damage = 1,
      damageType = fk.ThunderDamage,
      skillName = self.name
    })
    if not to.dead then
    room:askForDiscard(to, 1, 1, true, self.name, false)
      if not to.dead then
        to:drawCards(1, self.name)
      end
    end
  end
}
tey__chengjing_tey__drowningSkill.cardSkill = true
Fk:addSkill(tey__chengjing_tey__drowningSkill)

local tey__chengjing_buff = fk.CreateTriggerSkill{
  name = "#tey__chengjing_buff",
  events = {fk.PreCardEffect},
  mute = true,
  can_trigger = function(self, event, target, player, data)
    -- 这里技能不需要判断是否失效，因为刘渊琢政实际上是本体失效+特殊时机发动（类似南华的组合技能），以前的写法被琢政改时机后就不会背水所有效果了
    return player:hasSkill("tey__chengjing", true) and data.from == player.id and data.card.skillName == "tey__chengjing"
  end,
  on_cost = Util.TrueFunc,
  on_use = function(self, event, target, player, data)
    local card = data.card:clone()
    local c = table.simpleClone(data.card)
    for k, v in pairs(c) do
      card[k] = v
    end
    if data.card.trueName == "analeptic" then
    card.skill = tey__chengjing_analepticSkill
    elseif data.card.trueName == "chasing_near" then
    card.skill = tey__chengjing_chasingNearSkill
    elseif data.card.trueName == "tey__drowning" then
    card.skill = tey__chengjing_tey__drowningSkill
    end
    data.card = card
  end,
}
local tey__chengjing = fk.CreateTriggerSkill{
  name = "tey__chengjing",
  anim_type = "offensive",
  events = {"fk.GeneralAppeared", fk.EventPhaseStart},
  can_trigger = function(self, event, target, player, data)
    if event == "fk.GeneralAppeared" then
    return player:hasSkill("tey__chengjing") and target == player
    elseif event == fk.EventPhaseStart then
    return player:hasSkill("tey__chengjing") and target == player and 
    (player.phase == Player.Discard or player.phase == Player.Play or player.phase == Player.Draw or player.phase == Player.Judge) and
    (table.contains(Fk.generals[player.general]:getSkillNameList(), self.name) or 
    (player.deputyGeneral ~= "" and table.contains(Fk.generals[player.deputyGeneral]:getSkillNameList(), self.name)))
    end -- 阶段发动绑武将牌单纯是因为扶摇神人刘渊
  end,
  on_cost = function(self, event, target, player, data)
    local prompt
    if event == "fk.GeneralAppeared" then
      prompt = "#tey__chengjing-invoke"
    elseif event == fk.EventPhaseStart then
      if player.phase == Player.Judge then
      prompt = "#tey__chengjing2-invoke1"
      elseif player.phase == Player.Draw then
      prompt = "#tey__chengjing2-invoke2"
      elseif player.phase == Player.Play then
      prompt = "#tey__chengjing2-invoke3"
      elseif player.phase == Player.Discard then
      prompt = "#tey__chengjing2-invoke4"
      end
    end
    return player.room:askForSkillInvoke(player, self.name, nil, prompt)
  end,
  on_use = function (self, event, target, player, data)
    if player:getMark("tey__chengjing1") == 0 and player:getMark("tey__chengjing2") == 0 
    and player:getMark("tey__chengjing3") == 0 then return false end
    local name 
    if player:getMark("tey__chengjing1") == 1 then
    name = "analeptic"
  elseif player:getMark("tey__chengjing2") == 1 then
    name = "chasing_near"
  elseif player:getMark("tey__chengjing3") == 1 then
    name = "tey__drowning"
    end
    local use = U.askForUseVirtualCard(player.room, player, name, nil, self.name, nil, true, true, false, true, nil, true)
    if use then
      if player:getMark("tey__chengjing1") == 1 then
        player.room:setPlayerMark(player, "tey__chengjing1", 0)
        player.room:setPlayerMark(player, "tey__chengjing3", 0)
        player.room:setPlayerMark(player, "tey__chengjing2", 1)
        player.room:setPlayerMark(player, "@@tey__chengjing1", 0)
        player.room:setPlayerMark(player, "@@tey__chengjing3", 0)
        player.room:setPlayerMark(player, "@@tey__chengjing2", 1)
      elseif player:getMark("tey__chengjing2") == 1 then
        player.room:setPlayerMark(player, "tey__chengjing1", 0)
        player.room:setPlayerMark(player, "tey__chengjing2", 0)
        player.room:setPlayerMark(player, "tey__chengjing3", 1)
        player.room:setPlayerMark(player, "@@tey__chengjing1", 0)
        player.room:setPlayerMark(player, "@@tey__chengjing2", 0)
        player.room:setPlayerMark(player, "@@tey__chengjing3", 1)
      elseif player:getMark("tey__chengjing3") == 1 then
        player.room:setPlayerMark(player, "tey__chengjing3", 0)
        player.room:setPlayerMark(player, "tey__chengjing2", 0)
        player.room:setPlayerMark(player, "tey__chengjing1", 1)
        player.room:setPlayerMark(player, "@@tey__chengjing3", 0)
        player.room:setPlayerMark(player, "@@tey__chengjing2", 0)
        player.room:setPlayerMark(player, "@@tey__chengjing1", 1)
      end
      use.card.skillName = "tey__chengjing"
      player.room:useCard(use)
     if #player.room.logic:getActualDamageEvents(1, function(e) return e.data[1].from == player end, Player.HistoryRTurn) == 0 then
      player.room:loseHp(player, 1, self.name)
     end
    if player:getMark("__hidden_general") == 0 and player:getMark("__hidden_deputy") == 0 then
      IntoHidden(player) --防止双将反复嵌套进入隐匿顶替掉主将的数据
    end
    end
  end,

  on_acquire = function (self, player, is_start)
    local room = player.room
    if player:getMark("tey__chengjing1") == 0 and player:getMark("tey__chengjing2") == 0 and player:getMark("tey__chengjing3") == 0 then
      room:setPlayerMark(player, "tey__chengjing1", 1)
      room:setPlayerMark(player, "tey__chengjing2", 0)
      room:setPlayerMark(player, "tey__chengjing3", 0)
    end
  end,
}

tey__chengjing:addRelatedSkill(tey__chengjing_buff)
Xiao:addSkill(tey__chengjing)
tey__chengjing.isHiddenSkill = true

Fk:loadTranslationTable{
  ["tey__Xiao"] = "魈", 
  ["#tey__Xiao"] = "护法夜叉",
  ["cv:tey__Xiao"] = "kinsen",
  ["illustrator:tey__Xiao"] = "ゆとりこ",
  ["designer:tey__Xiao"] = "幽蝶化烬",

  ["tey__chengjing"] = "骋靖",
  [":tey__chengjing"] = "隐匿。<a href='transform_skill_href'>转换技</a>，你登场后或你的主要阶段开始时，你可以视为使用执行所有效果的①【酒】②【逐近弃远】③【水淹七军】，"..
  "<a href='IntoHidden_href'>进入隐匿状态</a>。（若你本回合未造成过伤害，隐匿前你失去1点体力）<a href='tey__chengjing_href'>注释</a>",
  ["tey__chengjing_href"] = "执行所有效果：若一张牌有多个分支效果，则按照分支的顺序，无视前置条件，对目标执行效果。<br>".. 
  "水淹七军（锦囊，十周年版本）：出牌阶段，对一至两名角色使用：第一名角色受到1点雷电伤害并弃置一张牌，该角色以外的角色受到1点雷电伤害并摸一张牌。<br>".. 
  "<a href='tey__chengjing_detail_href'>或许可以再看看具体的注释？</a>",
  ["tey__chengjing_detail_href"] = "执行所有效果的具体结算：<br>酒（基本）：对你使用，你回复1点体力，本回合使用下一张【杀】伤害+1。<br>".. 
  "逐近弃远（锦囊）：对一名有牌的其他角色使用，你弃置其区域内一张牌，获得其区域内一张牌。<br>".. 
  "水淹七军（锦囊）：对一至两名角色使用，目标角色受到1点雷电伤害，弃置一张牌，摸一张牌。<br>",
  ["#tey__chengjing-invoke"] = "您已登场，是否发动 骋靖 ？",
  ["#tey__chengjing2-invoke1"] = "判定阶段开始，您是否发动 骋靖 ？",
  ["#tey__chengjing2-invoke2"] = "摸牌阶段开始，您是否发动 骋靖 ？",
  ["#tey__chengjing2-invoke3"] = "出牌阶段开始，您是否发动 骋靖 ？",
  ["#tey__chengjing2-invoke4"] = "弃牌阶段开始，您是否发动 骋靖 ？",
  ["@@tey__chengjing1"] = "骋靖 ①",
  ["@@tey__chengjing2"] = "骋靖 ②",
  ["@@tey__chengjing3"] = "骋靖 ③",
  ["tey__chengjing_analepticSkill"] = "骋靖",
  ["tey__chengjing_chasingNearSkill"] = "骋靖",
  ["tey__chengjing_drowningSkill"] = "骋靖",
  ["tey__chengjing_analeptic_skill"] = "酒",
  ["tey__chengjing_chasing_near_skill"] = "逐近弃远",
  ["tey__chengjing_drowning_skill"] = "水淹七军",

  ["$tey__chengjing1"] = "无聊。",
  ["$tey__chengjing2"] = "无用。",
  ["$tey__chengjing3"] = "无能。",
  ["$tey__chengjing4"] = "就此消失。",
  ["$tey__chengjing5"] = "靖妖傩舞。",
  ["~tey__Xiao"] = "这是…报应吗…",
} 

local tey__zhuanglin_active = fk.CreateActiveSkill{
  name = "tey__zhuanglin_active",
  card_num = 0,
  target_num = 1,
  interaction = function()
    local choices, all_choices = {}, {"Dehyapindian", "Dehyajuedou", "Dehyamouyi"}
    local mark = Self:getTableMark("@tey__zhuanglin")
    for _, id in ipairs(mark) do
      table.insertIfNeed(choices, id)
    end
    return UI.ComboBox {choices = choices, all_choices = all_choices}
  end,
  card_filter = Util.FalseFunc,
  target_filter = function(self, to_select, selected)
    local choice = self.interaction.data
    if #selected > 0 or to_select == Self.id or not choice then
      return false
    end
    local target = Fk:currentRoom():getPlayerById(to_select)
    if (not Self:canPindian(target) or Self:isKongcheng() or target:isKongcheng()) and choice == "Dehyapindian" then return false end
    if Self:isProhibited(target, Fk:cloneCard("duel")) and choice == "Dehyajuedou" then return false end
    return true
  end,
}
Fk:addSkill(tey__zhuanglin_active)
local tey__zhuanglin = fk.CreateTriggerSkill{
  name = "tey__zhuanglin",
  mute = true,
  anim_type = "masochism",
  events = {fk.EventPhaseStart, fk.TurnEnd},
  can_trigger = function(self, event, target, player, data)
    if player:hasSkill(self) then
    return (event == fk.EventPhaseStart and target == player and player.phase == Player.Start) 
    or (event == fk.TurnEnd and #player.room.logic:getEventsOfScope(GameEvent.ChangeHp, 1, function(e)
      local damage = e.data[5]
        return damage and damage.to == player
    end, Player.HistoryTurn) > 0)
    end
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
    local _, dat = room:askForUseActiveSkill(player, "tey__zhuanglin_active", "#tey__zhuanglin-active", true, nil, false)
    if dat then
      self.cost_data = {tos = dat.targets, choice = dat.interaction}
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local to = room:getPlayerById(self.cost_data.tos[1])
    local choice = self.cost_data.choice
    local mark = player:getTableMark("@tey__zhuanglin")
    table.removeOne(mark, choice)
    room:setPlayerMark(player, "@tey__zhuanglin", #mark > 0 and mark or 0)
    if #mark == 0 then
    room:setPlayerMark(player, "@tey__zhuanglin", {"Dehyapindian", "Dehyajuedou", "Dehyamouyi"})
    end
    local winner
    if choice == "Dehyapindian" then
      player:broadcastSkillInvoke(self.name, math.random(2))
      local pindian = player:pindian({to}, self.name)
      winner = pindian.results[to.id].winner
    elseif choice == "Dehyajuedou" then
      player:broadcastSkillInvoke(self.name, math.random(3,4))
      local duel = Fk:cloneCard("duel")
        duel.skillName = self.name
        local use = {from = player.id, tos = { {to.id} }, card = duel, extraUse = true}
        room:useCard(use)
        if use.damageDealt and use.damageDealt[to.id] then
        winner = player
        elseif use.damageDealt and use.damageDealt[player.id] then
        winner = to
        end
    elseif choice == "Dehyamouyi" then
      player:broadcastSkillInvoke(self.name, math.random(5,6))
      local x = math.random(5) --谋弈随机题库，可能随着迭代增加新的题目（私货）
      if x == 1 then
      local choices = U.doStrategy(room, player, to, {"tey__zhuanglin-raoxing","tey__zhuanglin-zhiqu"},
      {"tey__zhuanglin-maifu","tey__zhuanglin-qingchao"}, self.name, 1)
      if (choices[1] == "tey__zhuanglin-raoxing" and choices[2] == "tey__zhuanglin-qingchao") 
      or (choices[1] == "tey__zhuanglin-zhiqu" and choices[2] == "tey__zhuanglin-maifu") then
      winner = player
      elseif (choices[1] == "tey__zhuanglin-raoxing" and choices[2] == "tey__zhuanglin-maifu") 
      or (choices[1] == "tey__zhuanglin-zhiqu" and choices[2] == "tey__zhuanglin-qingchao") then
      winner = to
      end
      elseif x == 2 then
      local choices = U.doStrategy(room, player, to, {"tey__zhuanglin-jiexiang","tey__zhuanglin-jianbi"},
      {"tey__zhuanglin-liugun","tey__zhuanglin-zhuanfei"}, self.name, 1)
      if (choices[1] == "tey__zhuanglin-jiexiang" and choices[2] == "tey__zhuanglin-zhuanfei") 
      or (choices[1] == "tey__zhuanglin-jianbi" and choices[2] == "tey__zhuanglin-liugun") then
      winner = player
      elseif (choices[1] == "tey__zhuanglin-jiexiang" and choices[2] == "tey__zhuanglin-liugun") 
      or (choices[1] == "tey__zhuanglin-jianbi" and choices[2] == "tey__zhuanglin-zhuanfei") then
      winner = to
      end
      elseif x == 3 then
      local choices = U.doStrategy(room, player, to, {"tey__zhuanglin-changgong","tey__zhuanglin-zhaoyi"},
      {"tey__zhuanglin-wuji","tey__zhuanglin-liangzhu"}, self.name, 1)
      if (choices[1] == "tey__zhuanglin-changgong" and choices[2] == "tey__zhuanglin-liangzhu") 
      or (choices[1] == "tey__zhuanglin-zhaoyi" and choices[2] == "tey__zhuanglin-wuji") then
      winner = player
      elseif (choices[1] == "tey__zhuanglin-changgong" and choices[2] == "tey__zhuanglin-wuji") 
      or (choices[1] == "tey__zhuanglin-zhaoyi" and choices[2] == "tey__zhuanglin-liangzhu") then
      winner = to
      end
      elseif x == 4 then
      local choices = U.doStrategy(room, player, to, {"tey__zhuanglin-1","tey__zhuanglin-2"},
      {"tey__zhuanglin-4","tey__zhuanglin-3"}, self.name, 1)
      if (choices[1] == "tey__zhuanglin-1" and choices[2] == "tey__zhuanglin-3") 
      or (choices[1] == "tey__zhuanglin-2" and choices[2] == "tey__zhuanglin-4") then
      winner = player
      elseif (choices[1] == "tey__zhuanglin-1" and choices[2] == "tey__zhuanglin-4") 
      or (choices[1] == "tey__zhuanglin-2" and choices[2] == "tey__zhuanglin-3") then
      winner = to
      end
      elseif x == 5 then
      local choices = U.doStrategy(room, player, to, {"tey__zhuanglin-5","tey__zhuanglin-6"},
      {"tey__zhuanglin-8","tey__zhuanglin-7"}, self.name, 1)
      if (choices[1] == "tey__zhuanglin-5" and choices[2] == "tey__zhuanglin-7") 
      or (choices[1] == "tey__zhuanglin-6" and choices[2] == "tey__zhuanglin-8") then
      winner = player
      elseif (choices[1] == "tey__zhuanglin-5" and choices[2] == "tey__zhuanglin-8") 
      or (choices[1] == "tey__zhuanglin-6" and choices[2] == "tey__zhuanglin-7")then
      winner = to
      end
      end
    end 
    if winner then
    local reward = {}
    local mark2 = player:getTableMark("tey__zhuanglin-name")
    for _, id in ipairs(mark2) do
      table.insertIfNeed(reward, id)
    end
    local use = U.askForUseVirtualCard(player.room, winner, reward, nil, self.name, nil, false, true, false, true, nil, false)
    if use then
    local name = use.card.name
    table.removeOne(mark2, name)
    room:setPlayerMark(player, "tey__zhuanglin-name", #mark2 > 0 and mark2 or 0)
    if #mark2 == 0 then
    room:setPlayerMark(player, "tey__zhuanglin-name", {"peach","duel","ex_nihilo"})
    end
    end
    end
  end,

  on_acquire = function (self, player, is_start)
    player.room:setPlayerMark(player, "@tey__zhuanglin", {"Dehyapindian", "Dehyajuedou", "Dehyamouyi"})
    player.room:setPlayerMark(player, "tey__zhuanglin-name", {"peach","duel","ex_nihilo"})
  end,
  on_lose = function (self, player, is_death)
    local room = player.room
    room:setPlayerMark(player, "@tey__zhuanglin", 0)
    room:setPlayerMark(player, "tey__zhuanglin-name", 0)
  end,
}
Dehya:addSkill(tey__zhuanglin)

Fk:loadTranslationTable{
  ["tey__Dehya"] = "迪希雅", 
  ["#tey__Dehya"] = "炽鬃之狮",
  ["cv:tey__Dehya"] = "陈雨",
  ["illustrator:tey__Dehya"] = "suzurin",
  ["designer:tey__Dehya"] = "幽蝶化烬",

  ["tey__zhuanglin"] = "妆凛",
  [":tey__zhuanglin"] = "准备阶段，或你受到过伤害的回合结束后，你可以选择未选择过的一项，对一名其他角色：拼点/对策/视为使用【决斗】，"..
  "赢者视为使用所有角色未选择过的牌名：【桃】/【决斗】/【无中生有】。选项/牌名均被选择过后，均视为未选择过。",
  ["Dehyapindian"] = "拼点",
  ["Dehyajuedou"] = "决斗",
  ["Dehyamouyi"] = "谋弈",
  ["@tey__zhuanglin"] = "",
  ["#tey__zhuanglin-active"] = "妆凛：你可以对一名角色执行一项效果，赢者（若为对策则为成功者，发起者失败则对方成功）可使用额外的牌。",
  ["tey__zhuanglin_active"] = "妆凛",

  ["tey__zhuanglin-raoxing"] = "避其锋芒",
  ["tey__zhuanglin-qingchao"] = "倾巢出动",
  ["tey__zhuanglin-maifu"] = "小路埋伏",
  ["tey__zhuanglin-zhiqu"] = "大道行进",
  [":tey__zhuanglin-raoxing"] = "避其锋芒：若对方“倾巢出动”则你赢，若对方“小路埋伏”则你输。"..
  "<br><font color='grey'>打的凶不一定赢，脚底抹油才是成功。赌上大贤者的名号，我猜小草王找不到我！",
  [":tey__zhuanglin-zhiqu"] = "大道行进：若对方“小路埋伏”则你赢，若对方“倾巢出动”则你输。"..
  "<br><font color='grey'>不论怎么讲，决战战力，是一神对两只蝼蚁，优势在我！————某个除名的畜鸣者",
  [":tey__zhuanglin-maifu"] = "小路埋伏：若对方“避其锋芒”则你赢，若对方“大道行进”则你输。"..
  "<br><font color='grey'>难怪打了这么久无相之草，它都不肯承认自己是大贤者，原来真身躲在这里啊...",
  [":tey__zhuanglin-qingchao"] = "倾巢出动：若对方“大道行进”则你赢，若对方“避其锋芒”则你输。"..
  "<br><font color='grey'>一众凡夫对机械伪神，这是一碗半生玛萨拉，半生就半生，也要把它喝下去！",

  ["tey__zhuanglin-jiexiang"] = "街巷周旋",
  ["tey__zhuanglin-jianbi"] = "坚壁固垒",
  ["tey__zhuanglin-liugun"] = "一秒六棍",
  ["tey__zhuanglin-zhuanfei"] = "力大砖飞",
  [":tey__zhuanglin-jiexiang"] = "街巷周旋：若对方“力大砖飞”则你赢，若对方“一秒六棍”则你输。"..
  "<br><font color='grey'>他们都是大韩民国的军人，怎么会向他们要保护的民众开枪呢？对，对吗？",
  [":tey__zhuanglin-jianbi"] = "坚壁固垒：若对方“一秒六棍”则你赢，若对方“力大砖飞”则你输。"..
  "<br><font color='grey'>默可能学了点高筑墙广积粮缓称王的道理，但他们学会说的道理不太可能。",
  [":tey__zhuanglin-liugun"] = "一秒六棍：若对方“街巷周旋”则你赢，若对方“坚壁固垒”则你输。"..
  "<br><font color='grey'>六棍打碎光州魂，长官我是大韩人！挥棍有速度，落棍有力度，甩棍有温度！",
  [":tey__zhuanglin-zhuanfei"] = "力大砖飞：若对方“坚壁固垒”则你赢，若对方“街巷周旋”则你输。"..
  "<br><font color='grey'>人人拥那啥，他才不乱？乱不乱不知道，这点火力还想起兵怕不是一炮没了。",

  ["tey__zhuanglin-changgong"] = "入阵夺旗",
  ["tey__zhuanglin-zhaoyi"] = "鸷刎断念",
  ["tey__zhuanglin-wuji"] = "挥袂易形",
  ["tey__zhuanglin-liangzhu"] = "化蝶再舞",
  [":tey__zhuanglin-changgong"] = "入阵夺旗：若对方“化蝶再舞”则你赢，若对方“挥袂易形”则你输。"..
  "<br><font color='grey'>每一个设计师在打开新月杀某些扩展包之前都有过一个梦想：技能至多摸三张。",
  [":tey__zhuanglin-zhaoyi"] = "鸷刎断念：若对方“挥袂易形”则你赢，若对方“化蝶再舞”则你输。"..
  "<br><font color='grey'>错误的世界没有正确的活法，四色的灯盏渐次熄灭，只有三张和唯一燃起烈火。",
  [":tey__zhuanglin-wuji"] = "挥袂易形：若对方“入阵夺旗”则你赢，若对方“鸷刎断念”则你输。"..
  "<br><font color='grey'>玩过牌系的一睁眼就听见“义不独生”，已经准备走...元直莫慌，石韬来也！",
  [":tey__zhuanglin-liangzhu"] = "化蝶再舞：若对方“鸷刎断念”则你赢，若对方“入阵夺旗”则你输。"..
  "<br><font color='grey'>自从庞统遁入天牢，世人便将李昭仪凌厉攻势下重获新生的希望交给了梁祝。",

  ["tey__zhuanglin-1"] = "维什戴尔",
  ["tey__zhuanglin-2"] = "那维莱特",
  ["tey__zhuanglin-3"] = "飞天马桶",
  ["tey__zhuanglin-4"] = "黄金龙兽",
  [":tey__zhuanglin-1"] = "维什戴尔：若对方“飞天马桶”则你赢，若对方“黄金龙兽”则你输。"..
  "<br><font color='grey'>除了不能破隐匿和次数盾以外，明日方舟几乎完美的存在，很好数值，使我大脑皮层光滑。",
  [":tey__zhuanglin-2"] = "那维莱特：若对方“黄金龙兽”则你赢，若对方“飞天马桶”则你输。"..
  "<br><font color='grey'>除了不能破水免和怕打断以外，原神里面几乎完美的存在，很好机制，使我大脑皮层光滑。",
  [":tey__zhuanglin-3"] = "黄金龙兽：若对方“维什戴尔”则你赢，若对方“那维莱特”则你输。"..
  "<br><font color='grey'>白条逃不出海鲜齐发，芙宁娜的气氛已经推向了高潮。彼方传来蛋糕的气息，想必胜局已定。",
  [":tey__zhuanglin-4"] = "飞天马桶：若对方“那维莱特”则你赢，若对方“维什戴尔”则你输。"..
  "<br><font color='grey'>隐匿躲不过爆裂黎明，伊内斯的影哨已经看破了阴霾。远处飘来土豆的香味，看来大获全胜。",

  ["tey__zhuanglin-5"] = "点燃星海",
  ["tey__zhuanglin-6"] = "技术革命",
  ["tey__zhuanglin-7"] = "忆域迷因",
  ["tey__zhuanglin-8"] = "梦境之主",
  [":tey__zhuanglin-5"] = "点燃星海：若对方“忆域迷因”则你赢，若对方“梦境之主”则你输。"..
  "<br><font color='grey'>自己上弱点自己击破，星穹铁道顶尖的存在，很好机制，使我大脑皮层光滑。",
  [":tey__zhuanglin-6"] = "技术革命：若对方“梦境之主”则你赢，若对方“忆域迷因”则你输。"..
  "<br><font color='grey'>自己叠数值自己连破，重返未来顶尖的存在，很好数值，使我大脑皮层光滑。",
  [":tey__zhuanglin-7"] = "忆域迷因：若对方“技术革命”则你赢，若对方“点燃星海”则你输。"..
  "<br><font color='grey'>打这种怪物真的需要dot吗，直接用击破打伤害不就好了？",
  [":tey__zhuanglin-8"] = "梦境之主：若对方“点燃星海”则你赢，若对方“技术革命”则你输。"..
  "<br><font color='grey'>打这种怪物真的需要收割吗，直接用电能轰过去不就好了？",

  ["$tey__zhuanglin1"] = "不用留情。",
  ["$tey__zhuanglin2"] = "你撑得住吗？",
  ["$tey__zhuanglin3"] = "在这，打垮你！",
  ["$tey__zhuanglin4"] = "把牙咬紧点！",
  ["$tey__zhuanglin5"] = "哼…有点本事。",
  ["$tey__zhuanglin6"] = "这不是正好？",
  ["~tey__Dehya"] = "佣兵的…宿命…",
} 

Fk:loadTranslationTable{
  ["tey__Xiangling"] = "香菱", 
  ["#tey__Xiangling"] = "万民百味",
  ["cv:tey__Xiangling"] = "",
  ["illustrator:tey__Xiangling"] = "",
  ["designer:tey__Xiangling"] = "幽蝶化烬",

  ["tey__yaoxiang"] = "肴享",
  [":tey__yaoxiang"] = "",
  ["tey__zhenchang"] = "珍尝",
  [":tey__zhenchang"] = "",

  ["$tey__yaoxiang1"] = "",
  ["$tey__yaoxiang2"] = "",
  ["$tey__zhenchang1"] = "",
  ["$tey__zhenchang2"] = "",
  ["~tey__Xiangling"] = "…",
} 

local tey__zhangxia = fk.CreateTriggerSkill{
  name = "tey__zhangxia",
  anim_type = "switch",
  events = {fk.TargetSpecifying},
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(self) and data.card.trueName == "slash" and player:usedSkillTimes(self.name, Player.HistoryTurn) == 0 and
    #table.filter(AimGroup:getAllTargets(data.tos), function (id) return player:inMyAttackRange(player.room:getPlayerById(id)) end) > 0
    and data.firstTarget
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
    local targets = table.filter(AimGroup:getAllTargets(data.tos), function (id)
      return not room:getPlayerById(id).dead and player:inMyAttackRange(room:getPlayerById(id)) 
    end)
    if #targets == 1 then
      if room:askForSkillInvoke(player, self.name, nil, "#tey__zhangxia-invoke::" .. targets[1]) then
        self.cost_data = targets
        return true
      end
    else
      targets = room:askForChoosePlayers(player, targets, 1, 1, "#tey__zhangxia-choose", self.name, true, false)
      if #targets > 0 then
        self.cost_data = targets
        return true
      end
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    AimGroup:cancelTarget(data, self.cost_data[1])
    if room:getCardArea(data.card) == Card.Processing and data.card.subcards and (#data.card.subcards == 1 or not data.card:isVirtual()) then --实体牌为1才能移
      local success, dat = room:askForUseActiveSkill(player, "teyvat__cardplace", "#tey__zhangxia_place", false,
      {all_choices_exclu = {"PlaceEquip", "TrueDelay", "AsLe", "AsBing", "ToHand"},
      only_target = {player.id}, only_card = data.card:isVirtual() and data.card.subcards or {data.card.id},  
      expand_pile = data.card:isVirtual() and data.card.subcards or {data.card.id}})
        if success then
        local cards = dat.cards
        local choice = dat.interaction
        room:addTableMark(player, "tey__zhangxia-phase", {player.id, dat.cards[1], target.id})
        if choice == "PlaceEquip" then
        room:moveCardTo(dat.cards, Player.Equip, player, fk.ReasonJustMove, self.name, nil, true, player.id)
        elseif choice == "TrueDelay" then
        room:moveCardTo(dat.cards, Player.Judge, player, fk.ReasonJustMove, self.name, nil, true, player.id)
      elseif choice == "AsLe" then
        local card = Fk:cloneCard("indulgence")
        card:addSubcard(dat.cards[1])
        player:addVirtualEquip(card)
        room:moveCardTo(card, Player.Judge, player, fk.ReasonJustMove, self.name, nil, true, player.id)
      elseif choice == "AsBing" then
        local card = Fk:cloneCard("supply_shortage")
        card:addSubcard(dat.cards[1])
        player:addVirtualEquip(card)
        room:moveCardTo(card, Player.Judge, player, fk.ReasonJustMove, self.name, nil, true, player.id)
      elseif choice == "ToHand" then
        room:moveCardTo(dat.cards, Player.Hand, player, fk.ReasonJustMove, self.name, nil, true, player.id, "@@ShownCards-inhand")
        end
      end
    else
      room:addTableMark(player, "tey__zhangxia1-phase", {player.id, target.id}) --不能移牌，直接阶段结束触发后续
    end
  end,
}
local tey__zhangxia_trigger = fk.CreateTriggerSkill{
  name = "#tey__zhangxia_trigger",
  mute = true,
  events = {fk.EventPhaseEnd},
  can_trigger = function(self, event, target, player, data)
    if player:getMark("tey__zhangxia-phase") ~= 0 then
      for _, t in ipairs(player:getMark("tey__zhangxia-phase")) do
        local p = player.room:getPlayerById(t[1])
        local b = player.room:getPlayerById(t[3])
        if p and b and not table.contains(p:getCardIds("ej"), t[2]) then
          return true
        end
      end
    elseif player:getMark("tey__zhangxia1-phase") ~= 0 then
      for _, t in ipairs(player:getMark("tey__zhangxia1-phase")) do
        local p = player.room:getPlayerById(t[1])
        local b = player.room:getPlayerById(t[2])
        if p and b then
          return true
        end
      end
    end
  end,
  on_cost = Util.TrueFunc,
  on_use = function(self, event, target, player, data)
    local room = player.room
    if player:getMark("tey__zhangxia-phase") ~= 0 then
    for _, t in ipairs(player:getMark("tey__zhangxia-phase")) do --如果移牌且不在场上的情况
      local p = player.room:getPlayerById(t[3])
      if p then
        player:broadcastSkillInvoke("tey__zhangxia")
        p:drawCards(1, "tey__zhangxia")
        if p:canUseTo(Fk:cloneCard("unexpectation"), player, { bypass_times = true, bypass_distances= true }) then
          local card = room:askForCard(p, 1, 1, true, "tey__zhangxia", false, ".", "#tey__zhangxia_use::"..player.id)
          if #card > 0 then
            local unexpectation = Fk:cloneCard("unexpectation")
            unexpectation.skillName = "tey__zhangxia"
            for _, id in ipairs(card) do
              unexpectation:addSubcard(id)
            end
            if p:canUseTo(unexpectation, player, { bypass_times = true, bypass_distances= true }) then
            room:useCard{
              from = p.id,
              card = unexpectation,
              tos = { { player.id } },
              extraUse = true,
            }
            end
          end
        end
      end
    end
  elseif player:getMark("tey__zhangxia1-phase") ~= 0 then
    for _, t in ipairs(player:getMark("tey__zhangxia1-phase")) do --如果未能移牌的情况
      local p = player.room:getPlayerById(t[2])
      if p then
        player:broadcastSkillInvoke("tey__zhangxia")
        p:drawCards(1, "tey__zhangxia")
        if p:canUseTo(Fk:cloneCard("unexpectation"), player, { bypass_times = true, bypass_distances= true }) then
          local card = room:askForCard(p, 1, 1, true, "tey__zhangxia", false, ".", "#tey__zhangxia_use::"..player.id)
          if #card > 0 then
            local unexpectation = Fk:cloneCard("unexpectation")
            unexpectation.skillName = "tey__zhangxia"
            for _, id in ipairs(card) do
              unexpectation:addSubcard(id)
            end
            if p:canUseTo(unexpectation, player, { bypass_times = true, bypass_distances= true }) then
            room:useCard{
              from = p.id,
              card = unexpectation,
              tos = { { player.id } },
              extraUse = true,
            }
            end
          end
        end
      end
    end
  end  
  end,
}
local tey__jianhong = fk.CreateViewAsSkill{
  name = "tey__jianhong",
  pattern = "archery_attack",
  anim_type = "offensive",
  prompt = "#tey__jianhong",
  min_card_num = 2,
  card_filter = function (self, to_select, selected, player)
    local c = Fk:getCardById(to_select)
    return c.trueName == "slash" and table.every(selected, function (id)
      return Fk:getCardById(id).trueName == c.trueName
    end)
  end,
  view_as = function (self, cards)
    if #cards <= 1 then
      return
    end
    local card = Fk:cloneCard("archery_attack")
    card.skillName = self.name
    card:addSubcards(cards)
    return card
  end,
  enabled_at_response = function (self,player,response)
    return not response
  end,
  enabled_at_play = Util.TrueFunc;
}
local tey__jianhong_trigger = fk.CreateTriggerSkill{
  name = "#tey__jianhong_trigger",
  anim_type = "offensive",
  events = {fk.TargetSpecifying, fk.CardUseFinished},
  can_trigger = function(self, event, target, player, data)
    if event == fk.TargetSpecifying then
    return target == player and data.card.trueName == "archery_attack" and data.card.skillName == "tey__jianhong" 
    and data.firstTarget and data.card and #data.card.subcards > 0
    else
      if data.extra_data and data.extra_data.tey__jianhong and not player.dead then
        local use = table.simpleClone(data.extra_data.tey__jianhong)
        if use.from == player.id then
          local card = Fk:cloneCard(data.card.name)
          card.skillName = "tey__jianhong"
          if player:prohibitUse(card) then return false end
          use.card = card
          local room = player.room
          local to = room:getPlayerById(use.to)
          if not to.dead then
            local tos = {use.to}
            self.cost_data = {
              from = player.id,
              tos = table.map(tos, function(pid) return { pid } end),
              card = card,
              extraUse = true
            }
            return true
          end
        end
      end
    end
  end,
  on_cost = Util.TrueFunc,
  on_use = function(self, event, target, player, data)
    local room = player.room
    player:broadcastSkillInvoke("tey__jianhong")
    if event == fk.TargetSpecifying then
    local targets = table.map(table.filter(room:getOtherPlayers(player, false), function(p)
      return not player:isProhibited(p, data.card) end), Util.IdMapper)
    local n = math.min(#targets, #data.card.subcards)
    local tos = room:askForChoosePlayers(player, targets, 1, n, "#tey__jianhong-choose:::"..n, self.name, false)
    for _, id in ipairs(AimGroup:getAllTargets(data.tos)) do
      AimGroup:cancelTarget(data, id)
    end
    for _, id in ipairs(tos) do
      AimGroup:addTargets(room, data, id)
    end
    if #tos < #data.card.subcards then
      if player.shield == 0 then
        room:changeShield(player, 1)
      end
      local add = room:askForChoosePlayers(player, AimGroup:getAllTargets(data.tos), 1, 1, "#tey__jianhong-add", self.name, false)
      data.extra_data = data.extra_data or {}
      data.extra_data.tey__jianhong = {
        from = player.id,
        to = add[1],
      }
    end
  else
    player.room:useCard(table.simpleClone(self.cost_data))
    end
  end,
}
tey__zhangxia:addRelatedSkill(tey__zhangxia_trigger)
tey__jianhong:addRelatedSkill(tey__jianhong_trigger)
Xingqiu:addSkill(tey__zhangxia)
Xingqiu:addSkill(tey__jianhong)

Fk:loadTranslationTable{
  ["tey__Xingqiu"] = "行秋", 
  ["#tey__Xingqiu"] = "少年春裳薄",
  ["cv:tey__Xingqiu"] = "唐雅菁",
  ["illustrator:tey__Xingqiu"] = "Ajahweea",
  ["designer:tey__Xingqiu"] = "幽蝶化烬",

  ["tey__zhangxia"] = "仗侠",
  [":tey__zhangxia"] = "每回合限一次，你攻击范围内的角色成为【杀】的目标时，你可以取消之，将此【杀】<a href='teyplace__shown_href'>明置于你的区域内</a>。"..
  "本阶段结束后，若此牌不在你的场上，原使用者摸一张牌，将一张牌当【出其不意】对你使用。",
  ["tey__jianhong"] = "剑虹",
  [":tey__jianhong"] = "你可以将至少两张【杀】当目标上限等量的【万箭齐发】使用，若目标数未达到上限，你将护甲补至1且结算后视为对一个目标再使用一次。",

  ["teyplace__shown_href"] = "对应实体牌数为1方可置入（不能置入直接满足牌不在场上），移动规则如下：<br>装备牌--可以置入装备区；<br>"..
  "判定牌--可以置入判定区；<br>以上均否--可按红乐黑兵的方式置入判定区，或置入手牌区并明置。（明置不支持蓄谋牌）",

  ["tey__zhangxia_trigger"] = "仗侠",
  ["#tey__zhangxia-choose"] = "是否发动 仗侠，取消一名角色为【杀】的目标？",
  ["#tey__zhangxia-invoke"] = "是否对%dest发动 仗侠，取消其为【杀】的目标？",
  ["#tey__zhangxia_place"] = "仗侠：请将此【杀】的实体牌明置于你的区域内",
  ["#tey__zhangxia_use"] = "仗侠：请将一张牌当【出其不意】使用，报复不让你出杀的角色 %dest。",
  ["#tey__jianhong"] = "剑虹：选择至少两张【杀】当【万箭齐发】使用，且目标上限也等量。",
  ["#tey__jianhong_trigger"] = "剑虹",
  ["#tey__jianhong-choose"] = "剑虹：请指定一至%arg名角色，这些角色成为新的目标。",
  ["#tey__jianhong-add"] = "剑虹：请令一名目标于结算后再被视为使用【万箭齐发】。",

  ["$tey__zhangxia1"] = "有时明月无人夜，独向昭潭制恶龙。",
  ["$tey__zhangxia2"] = "某虽不才，仍愿为君略尽绵薄。",
  ["$tey__zhangxia3"] = "请从绝处，读我侠义。",
  ["$tey__jianhong1"] = "织诗成锦。",
  ["$tey__jianhong2"] = "裁雨留虹。",
  ["$tey__jianhong3"] = "雨线难画。",
  ["~tey__Xingqiu"] = "灯华易散…我是知道的。",
} 

Fk:loadTranslationTable{
  ["tey__Yelan"] = "夜兰", 
  ["#tey__Yelan"] = "兰生幽谷",
  ["cv:tey__Yelan"] = "徐慧",
  ["illustrator:tey__Yelan"] = "Ten",
  ["designer:tey__Yelan"] = "幽蝶化烬",

  ["tey__zhengfa"] = "整发",
  [":tey__zhengfa"] = "隐匿。锁定技，你登场的回合结束后，将手牌摸至三张，若未摸牌，你使用当前手牌无距离限制。",
  ["tey__jiancha"] = "间察",
  [":tey__jiancha"] = "准备阶段，你可以观看一名其他角色的手牌并弃置其区域内一张牌，再重铸你区域内一张牌。"..
  "两张牌中，若其中一张可以抵消另一张，你视为对其使用【杀】，否则其视为对你使用【杀】。",
  ["tey__jielan"] = "截澜",
  [":tey__jielan"] = "你响应其他角色的牌后，你可以令其本回合不能使用（对自己除外）或打出牌，然后若其本回合未再失去过牌，本回合结束后你回复1点体力。",

  ["$tey__zhengfa1"] = "",
  ["$tey__zhengfa2"] = "",
  ["$tey__jiancha1"] = "",
  ["$tey__jiancha2"] = "",
  ["$tey__jielan1"] = "",
  ["$tey__jielan2"] = "",
  ["~tey__Yelan"] = "…",
} 

local tey__xianchun = fk.CreateTriggerSkill{
  name = "tey__xianchun",
  events = {fk.CardRespondFinished, fk.CardUseFinished},
  anim_type = "masochism",
  can_trigger = function(self, event, target, player, data)
    local room = player.room
    local to
    if player:hasSkill(self) and data.responseToEvent and data.responseToEvent.from and player:usedSkillTimes(self.name, Player.HistoryTurn) < 1 
    and not (room:getPlayerById(data.responseToEvent.from):isKongcheng() and player:isKongcheng()) then --只要使用者和蓝砚有一个有手牌就可以
      to = data.responseToEvent.from
    end
    if to then
      self.cost_data = {tos = {to}}
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local to = room:getPlayerById(self.cost_data.tos[1])
    local get = player.room:askForChoosePlayers(player, table.map(room:getOtherPlayers(to), Util.IdMapper), 1, 1, "#tey__xianchun-choose", self.name, false)
    local moveInfos = {}
    if #to:getCardIds(Player.Hand) > 0 then
      local cards1 = room:askForCardsChosen(player, to, 1, 1, "h", self.name)
        if #cards1 > 0 then
          table.insert(moveInfos, {
            from = to.id,
            ids = cards1,
            to = get[1],
            toArea = Card.PlayerHand,
            moveReason = fk.ReasonGive,
            proposer = player.id,
            skillName = self.name,
          })
        end
    end
    if #player:getCardIds(Player.Hand) > 0 then
      local cards2 = room:askForCardsChosen(player, player, 1, 1, "h", self.name)
        if #cards2 > 0 then
          table.insert(moveInfos, {
            from = player.id,
            ids = cards2,
            to = get[1],
            toArea = Card.PlayerHand,
            moveReason = fk.ReasonGive,
            proposer = player.id,
            skillName = self.name,
          })
        end
    end
    room:moveCards(table.unpack(moveInfos))
    local spring = room:getCardsFromPileByRule(".|3~5", 1, "allPiles")
    if player.dead then return end
    if #spring > 0 then
      room:moveCardTo(spring, Card.PlayerHand, player, fk.ReasonJustMove, self.name, nil, true, player.id)
    end
    if to.dead then return end
    local slash = room:getCardsFromPileByRule(".|.|.|.|thunder__slash", 1, "allPiles")
    if #slash > 0 then
      room:moveCardTo(slash, Card.PlayerHand, to, fk.ReasonJustMove, self.name, nil, true, player.id)
    end
  end,
}

local tey__fangchao = fk.CreateTriggerSkill{
  name = "tey__fangchao",
  switch_skill_name = "tey__fangchao",
  events = {fk.TargetConfirmed},
  anim_type = "defensive",
  can_trigger = function(self, event, target, player, data)
    if target == player and player:hasSkill(self) and data.card.is_damage_card and player:usedSkillTimes(self.name, Player.HistoryTurn) < 1 then
    return (player:getSwitchSkillState(self.name) == fk.SwitchYang and not player:isKongcheng()) or
    (player:getSwitchSkillState(self.name) == fk.SwitchYin and not player:isAllNude())
    end
  end,
  on_cost = function(self, event, target, player, data)
    if player:getSwitchSkillState(self.name) == fk.SwitchYang then
      local card = player.room:askForDiscard(player, 1, 1, false, self.name, true, ".", "#tey__fangchao-yang")
      return #card > 0
    else
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    if player:getSwitchSkillState(self.name, true) == fk.SwitchYang then
      player:setChainState(true)
      table.insertIfNeed(data.nullifiedTargets, player.id)
    else
      if not player:isAllNude() then
      room:setPlayerMark(player, "tey__fangchao_cards", player:getCardIds("j"))
      local success, dat = room:askForUseActiveSkill(player, "tey__fangchao_active", "#tey__fangchao_active", false)
        if success then
          local cards = dat.cards
          room:recastCard(cards, player, self.name)
        end
        if not player.dead then
          local to = room:askForChoosePlayers(player, table.map(room:getOtherPlayers(player), Util.IdMapper), 1, 1,
          "#tey__fangchao_chain", self.name, false)
          if #to > 0 then
            room:getPlayerById(to[1]):setChainState(true)
          end
        end
      end
    end
  end,
}
local tey__fangchao_active = fk.CreateActiveSkill{
  name = "tey__fangchao_active",
  mute = true,
  min_card_num = 1,
  max_card_num = 1,
  target_num = 0,
  expand_pile = function(self)
    return Self:getTableMark("tey__fangchao_cards")
  end,
}

Fk:addSkill(tey__fangchao_active)
Lanyan:addSkill(tey__xianchun)
Lanyan:addSkill(tey__fangchao)

Fk:loadTranslationTable{
  ["tey__Lanyan"] = "蓝砚", 
  ["#tey__Lanyan"] = "翦玉编春",
  ["cv:tey__Lanyan"] = "刘十四",
  ["illustrator:tey__Lanyan"] = "ルナクル",
  ["designer:tey__Lanyan"] = "幽蝶化烬",

  ["tey__xianchun"] = "衔春",
  [":tey__xianchun"] = "每回合限一次，一名角色使用的牌被响应后，你可以将其与你的各一张手牌交给另一名角色，然后你获得一张点数3～5的牌，其获得一张雷【杀】。",
  ["tey__fangchao"] = "纺巢",
  [":tey__fangchao"] = "转换技，每回合限一次，你成为伤害牌的目标后，阳：你可以弃置一张手牌并横置，令使用牌对你无效；阴：你重铸区域内一张牌，横置一名其他角色。",

  ["#tey__xianchun-choose"] = "衔春：请选择将要获得牌的一名角色！",
  ["#tey__fangchao-yang"] = "纺巢：（阳）你可以弃置一张手牌并横置，令使用牌对你无效。",
  ["tey__fangchao_active"] = "纺巢",
  ["#tey__fangchao_active"] = "纺巢：请重铸区域内的一张牌",
  ["#tey__fangchao_chain"] = "纺巢：请横置一名角色",
  [":tey__fangchao_yang"] = "转换技，每回合限一次，你成为伤害牌的目标后，"..
  "<font color=\"#E0DB2F\">阳：你可以弃置一张手牌并横置，令使用牌对你无效；</font>"..
  "<font color=\"gray\">阴：你重铸区域内一张牌，横置一名其他角色。</font>",
  [":tey__fangchao_yin"] = "转换技，每回合限一次，你成为伤害牌的目标后，"..
  "<font color=\"gray\">阳：你可以弃置一张手牌并横置，令使用牌对你无效；</font>"..
  "<font color=\"#E0DB2F\">阴：你重铸区域内一张牌，横置一名其他角色。</font>",

  ["$tey__xianchun1"] = "天暖燕子么搭窝窝，升雷扯闪么我家躲。",
  ["$tey__xianchun2"] = "赶不及躲雨了，那--安心淋雨吧，还省了跑步的力气。",
  ["$tey__fangchao1"] = "好的藤器经篾薄如绸，纬条细若丝，经久不坏…",
  ["$tey__fangchao2"] = "等等，我才编了两个结你怎么就…",
  ["~tey__Lanyan"] = "银铃…不响了…",
} 

local tey__yaoyou = fk.CreateTriggerSkill{
  name = "tey__yaoyou",
  frequency = Skill.Limited,
  events = {fk.RoundStart, fk.CardUseFinished},
  can_trigger = function(self, event, target, player, data)
    if event == fk.RoundStart then
      return player:hasSkill(self) and player:usedSkillTimes(self.name, Player.HistoryGame) == 0
    elseif event == fk.CardUseFinished then
      local targets = TargetGroup:getRealTargets(data.tos)
      return target == player and player:hasSkill(self) and (type(data.tos) ~= "table" or #targets == 0)
      and player:usedSkillTimes(self.name, Player.HistoryGame) == 0
    end
  end,
  on_cost = function(self, event, target, player, data)
    if event == fk.RoundStart then
      if player.room:askForSkillInvoke(player, self.name, data, "#tey__yaoyou-invoke1") then
        self.cost_data = "@@tey__yaoyou2"
        return true
      end
  elseif event == fk.CardUseFinished then
      if player.room:askForSkillInvoke(player, self.name, data, "#tey__yaoyou-invoke2") then
        self.cost_data = "@@tey__yaoyou1"
        return true
      end
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:setPlayerMark(player, self.cost_data, 1)
    local allCardNames = {}
    for _, id in ipairs(Fk:getAllCardIds()) do
      local card = Fk:getCardById(id)
      if not table.contains(allCardNames, card.name) and card.type == Card.TypeBasic then
        table.insert(allCardNames, card.name)
      end
    end
    if #allCardNames == 0 then return false end
    local cards = {}
    table.forEach(allCardNames, function(name)
      table.insert(cards, room:getCardsFromPileByRule(name, 1, "drawPile")[1])
    end)
    if #allCardNames < 2 then return false end
    for i = 1 , 2 , 1 do 
      if player.dead or #cards < 1 then break end
    local success, dat = room:askForUseActiveSkill(player, "teyvat__cardplace", "tey__yaoyou-put", false,
    {all_choices_exclu = {"ToHand"}, only_card = cards,  expand_pile = cards})
      if success then
        table.removeOne(cards, dat.cards[1])
        local to = room:getPlayerById(dat.targets[1])
        room:moveCardTo(dat.cards, Player.Hand, to, fk.ReasonGive, self.name, nil, true, player.id, "@@tey__yaoyou")
        local mark = player:getTableMark("@$tey__yaoyou")
        table.insertIfNeed(mark, dat.cards[1])
        room:setPlayerMark(player, "@$tey__yaoyou", #mark > 0 and mark or 0)
      end
    end
  end,

  refresh_events = {fk.RoundEnd},
  can_refresh = function (self, event, target, player, data)
    return player:hasSkill(self) and player:usedSkillTimes(self.name, Player.HistoryGame) > 0 and #player:getTableMark("@$tey__yaoyou") == 0
  end,
  on_refresh = function (self, event, target, player, data)
    player.room:loseHp(player, 1, self.name)
  end,
}

local tey__yaoyou_trigger = fk.CreateTriggerSkill{
  name = "#tey__yaoyou_trigger",
  events = {fk.RoundStart, fk.CardUseFinished},
  can_trigger = function(self, event, target, player, data)
    if event == fk.RoundStart then
      return player:hasSkill(self) and player:usedSkillTimes(tey__yaoyou.name, Player.HistoryGame) > 0
      and player:getMark("@@tey__yaoyou1") > 0 and #player:getTableMark("@$tey__yaoyou") > 0
    elseif event == fk.CardUseFinished then
      local targets = TargetGroup:getRealTargets(data.tos)
      return target == player and player:hasSkill(self) and (type(data.tos) ~= "table" or #targets == 0)
      and player:usedSkillTimes(tey__yaoyou.name, Player.HistoryGame) > 0 and player:getMark("@@tey__yaoyou2") > 0 and #player:getTableMark("@$tey__yaoyou") > 0
    end
  end,
  on_cost = function (self, event, target, player, data)
    local room = player.room
    local to = room:askForChoosePlayers(player, table.map(room:getOtherPlayers(player), Util.IdMapper), 1, 1,
      "#tey__yaoyou_trigger-ask", self.name, true)
    if #to > 0 then
      self.cost_data = to[1]
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    player:broadcastSkillInvoke(tey__yaoyou.name)
    local to = room:getPlayerById(self.cost_data)
    local choices = {"recover", "draw2"}
    if not to:isWounded() then
      table.removeOne(choices, "recover")
    end
    local choice = room:askForChoice(player, choices, self.name, "#tey__yaoyou-support::"..to.id, false, {"recover","draw2"})
    if choice == "recover" then
      room:recover({
        who = to,
        num = 1,
        recoverBy = player,
        skillName = self.name
      })
    else
      to:drawCards(2, self.name)
    end
  end,

  refresh_events = {fk.AfterCardsMove},
  can_refresh = function (self, event, target, player, data)
    for _, move in ipairs(data) do
      if move.toArea == Card.DiscardPile then
        for _, info in ipairs(move.moveInfo) do
          local id = info.cardId
          if Fk:getCardById(id):getMark("@@tey__yaoyou") > 0 then
            return player:hasSkill(tey__yaoyou) and player:usedSkillTimes(tey__yaoyou.name, Player.HistoryGame) > 0 and #player:getTableMark("@$tey__yaoyou") > 0
          end
        end
      end
    end
  end,
  on_refresh = function (self, event, target, player, data)
    for _, move in ipairs(data) do
      if move.toArea == Card.DiscardPile then
        for _, info in ipairs(move.moveInfo) do
          local id = info.cardId
          if Fk:getCardById(id):getMark("@@tey__yaoyou") > 0 then
            player.room:setCardMark(Fk:getCardById(id), "@@tey__yaoyou", 0)
            local mark = player:getTableMark("@$tey__yaoyou")
            table.removeOne(mark, info.cardId)
            player.room:setPlayerMark(player, "@$tey__yaoyou", #mark > 0 and mark or 0)
          end
        end
      end
    end
  end,
}

local tey__chenglang = fk.CreateTriggerSkill{
  name = "tey__chenglang",
  anim_type = "switch",
  events = {fk.TargetSpecifying},
  dynamic_desc = function(self, player)
    local mark1 = player:getMark("@tey__chenglang_next-phase")
    local mark2 = player:getMark("@tey__chenglang_last-phase")
    local x = math.max(#Fk:currentRoom().alive_players - player:usedSkillTimes(self.name, Player.HistoryPhase), 0)
    if mark1 ~= 0 then
    return "每阶段限角色数次（剩余"..x.."次），你对{".. Fk:translate(mark1, "zh_CN").."}使用牌时可以令此牌不可响应并摸一张牌，"..
    "将{}改为其下家。本阶段结束时复原本技能。"
    elseif mark2 ~= 0 then
    return "每阶段限角色数次（剩余"..x.."次），你对{".. Fk:translate(mark2, "zh_CN") .."}使用牌时可以令此牌不可响应并摸一张牌，"..
    "将{}改为其上家。本阶段结束时复原本技能。"
    end
  end,
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(self) and target == player and data.firstTarget and player:usedSkillTimes(self.name, Player.HistoryPhase) < #player.room.alive_players and
    ((player:getMark("tey__chenglang_next-phase") == 0 and player:getMark("tey__chenglang_last-phase") == 0 and
    #table.filter(AimGroup:getAllTargets(data.tos), function (id) return player.room:getPlayerById(id) ~= player end) > 0) or
    (player:getMark("tey__chenglang_next-phase") ~= 0 and 
    #table.filter(AimGroup:getAllTargets(data.tos), function (id) return id == player:getMark("tey__chenglang_next-phase") end) > 0) or
    (player:getMark("tey__chenglang_last-phase") ~= 0 and 
    #table.filter(AimGroup:getAllTargets(data.tos), function (id) return id == player:getMark("tey__chenglang_last-phase") end) > 0))
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
    local targets 
    if player:getMark("tey__chenglang_next-phase") == 0 and player:getMark("tey__chenglang_last-phase") == 0 then
      targets = table.filter(AimGroup:getAllTargets(data.tos), function (id) return player.room:getPlayerById(id) ~= player end)
    elseif player:getMark("tey__chenglang_next-phase") ~= 0 then
      targets = table.filter(AimGroup:getAllTargets(data.tos), function (id) return id == player:getMark("tey__chenglang_next-phase") end)
    elseif player:getMark("tey__chenglang_last-phase") ~= 0 then
      targets = table.filter(AimGroup:getAllTargets(data.tos), function (id) return id == player:getMark("tey__chenglang_last-phase") end)
    end
    if #targets == 1 then
      if room:askForSkillInvoke(player, self.name, nil, "#tey__chenglang-invoke::" .. targets[1]) then
        self.cost_data = targets
        return true
      end
    else
      targets = room:askForChoosePlayers(player, targets, 1, 1, "#tey__chenglang-choose", self.name, true, false)
      if #targets > 0 then
        self.cost_data = targets
        return true
      end
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    player:drawCards(1, self.name)
    local parentUseEvent = room.logic:getCurrentEvent():findParent(GameEvent.UseCard)
    data.disresponsive = true
    if parentUseEvent then
      local parentUseData = parentUseEvent.data[1]
      parentUseData.disresponsiveList = table.map(room.alive_players, Util.IdMapper)
    end
    if player:getMark("tey__chenglang_next-phase") == 0 and player:getMark("tey__chenglang_last-phase") == 0 then
      local choices = {"tey__chenglang_next","tey__chenglang_last"}
      local choice = room:askForChoice(player, choices, self.name, nil, false, {"tey__chenglang_next","tey__chenglang_last"})
      if choice == "tey__chenglang_next" then
      local temp = room:getPlayerById(self.cost_data[1]):getNextAlive()
      room:setPlayerMark(player, "tey__chenglang_next-phase", temp.id)
      room:setPlayerMark(player, "@tey__chenglang_next-phase", temp.general)
      else
      local temp = room:getPlayerById(self.cost_data[1]):getLastAlive()
      room:setPlayerMark(player, "tey__chenglang_last-phase", temp.id)
      room:setPlayerMark(player, "@tey__chenglang_last-phase", temp.general)
      end
    elseif player:getMark("tey__chenglang_next-phase") ~= 0 then
      local temp = room:getPlayerById(self.cost_data[1]):getNextAlive()
      room:setPlayerMark(player, "tey__chenglang_next-phase", temp.id)
      room:setPlayerMark(player, "@tey__chenglang_next-phase", temp.general)
    elseif player:getMark("tey__chenglang_last-phase") ~= 0 then
      local temp = room:getPlayerById(self.cost_data[1]):getLastAlive()
      room:setPlayerMark(player, "tey__chenglang_last-phase", temp.id)
      room:setPlayerMark(player, "@tey__chenglang_last-phase", temp.general)
    end
  end,
}
tey__yaoyou:addRelatedSkill(tey__yaoyou_trigger)
Mualani:addSkill(tey__yaoyou)
Mualani:addSkill(tey__chenglang)

Fk:loadTranslationTable{
  ["tey__Mualani"] = "玛拉妮", 
  ["#tey__Mualani"] = "大浪淘鲨",
  ["cv:tey__Mualani"] = "王晓彤",
  ["illustrator:tey__Mualani"] = "酥脆球球",
  ["designer:tey__Mualani"] = "幽蝶化烬",

  ["tey__yaoyou"] = "邀游",
  [":tey__yaoyou"] = "限定技。轮次开始时或你使用无目标的牌后，可以分配牌堆中两张不同名的基本牌。这些牌进入弃牌堆前，你于另一个时机可以令一名其他角色回复1点体力或摸两张牌。"..
  "这些牌进入弃牌堆后，每轮结束后你失去1点体力。",
  ["tey__chenglang"] = "乘浪",
  [":tey__chenglang"] = "每阶段限X次，你对{其他角色}使用牌时，可以令此牌不可响应并摸一张牌，将{}改为其上家/下家并删除另一项直至本阶段结束。X为角色数。",

  ["#tey__yaoyou_trigger"] = "邀游",
  ["@@tey__yaoyou"] = "邀游",
  ["@@tey__yaoyou1"] = "邀游 每轮开始时",
  ["@@tey__yaoyou2"] = "邀游 用无目标牌",
  ["#tey__yaoyou-invoke1"] = "邀游：是否发动本技能（当前/另一时机：本轮开始时/使用无目标牌后），分配两张基本牌，于另一个时机令角色回血或摸牌？",
  ["#tey__yaoyou-invoke2"] = "邀游：是否发动本技能（当前/另一时机：使用无目标牌后/本轮开始时），分配两张基本牌，于另一个时机令角色回血或摸牌？",
  ["#tey__yaoyou_trigger-ask"] = "邀游：是否选择一名角色，令其回血或摸牌？",
  ["#tey__yaoyou-support"] = "邀游：请令%dest回血或摸两张牌！",
  ["@$tey__yaoyou"] = "邀游",
  ["tey__yaoyou-put"] = "遥游：请将一张基本牌交给一名角色！",
  ["#tey__chenglang-choose"] = "是否发动 乘浪，选择一名角色与一个方向，摸一张牌，令使用牌不可响应？",
  ["#tey__chenglang-invoke"] = "是否对%dest发动 乘浪，摸一张牌，令使用牌不可响应？",
  ["tey__chenglang_next"] = "本阶段乘浪逆时针发动",
  ["tey__chenglang_last"] = "本阶段乘浪顺时针发动",
  ["@tey__chenglang_next-phase"] = "逆时-",
  ["@tey__chenglang_last-phase"] = "顺时-",

  ["$tey__yaoyou1"] = "有什么需求请随时伸长手臂向我示意哦！",
  ["$tey__yaoyou2"] = "站稳啦——美妙之旅要开始咯！",
  ["$tey__yaoyou3"] = "「出来玩」最重要的就是「出来」",
  ["$tey__yaoyou4"] = "想原地躺下晒太阳，晒完一面再翻个面。",
  ["$tey__chenglang1"] = "看我看我！祝你好运！",
  ["$tey__chenglang2"] = "巨浪——哗啦哗啦。",
  ["~tey__Mualani"] = "终点是…回家…",
} 

local natlan_weapons = {
  {"a_thousand_blazing_suns", Card.Heart, 12}, {"astral_vulture_crimson_plumage", Card.Heart, 6},
  {"peak_patrol_song", Card.Diamond, 7}, {"vivid_notions", Card.Diamond, 11},
  {"starcaller_watch", Card.Spade, 9},
  {"surf_up", Card.Club, 3}, {"fang_of_mountain_king", Card.Club, 10},
  {"mountain_bracing_bolt", Card.NoSuit, 0}, {"alley_hunter", Card.NoSuit, 0}
}
local tey__cangrong = fk.CreateTriggerSkill{
  name = "tey__cangrong",
  events = {fk.CardUseFinished},
  frequency = Skill.Compulsory,
  can_trigger = function(self, event, target, player, data)
    local mark = player:getTableMark("@tey__cangrong")
    return target == player and player:hasSkill(self.name) and not table.contains(mark, data.card:getSuitString(true)) 
    and data.card.type == Card.TypeBasic
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local mark = player:getTableMark("@tey__cangrong")
    table.insertIfNeed(mark, data.card:getSuitString(true))
    room:setPlayerMark(player, "@tey__cangrong", #mark > 0 and mark or 0)
    if #mark >= 4 then
      room:setPlayerMark(player, "@tey__cangrong", 0)
    end
    local cards = table.filter(U.prepareDeriveCards(room, natlan_weapons, "natlan_weapons"), function (id)
      return room:getCardArea(id) == Card.Void and Fk:getCardById(id).suit == data.card.suit
    end)
    if #cards > 0 then
      local active = {"PlaceEquipForce"}
      if player:getMark("baoju_to_cangrong") > 0 then
        active = {"PlaceEquipForce", "AsLe", "AsBing"}
      end
    local success, dat = room:askForUseActiveSkill(player, "teyvat__cardplace", "#tey__cangrong_place", true,
    {all_choices_exclu = active, only_card = cards,  expand_pile = cards})
      if success then
        local cards = dat.cards
        local choice = dat.interaction
        local to = room:getPlayerById(dat.targets[1])
        if choice == "PlaceEquipForce" then
        room:moveCardIntoEquip(to, cards[1], self.name, true, player)
      elseif choice == "AsLe" then
        local card = Fk:cloneCard("indulgence")
        card:addSubcard(dat.cards[1])
        to:addVirtualEquip(card)
        room:moveCardTo(card, Player.Judge, to, fk.ReasonJustMove, self.name, nil, true, player.id)
      elseif choice == "AsBing" then
        local card = Fk:cloneCard("supply_shortage")
        card:addSubcard(dat.cards[1])
        to:addVirtualEquip(card)
        room:moveCardTo(card, Player.Judge, to, fk.ReasonJustMove, self.name, nil, true, player.id)
        end
      else
        local skills = table.filter(target.player_skills, function(s) return not s:isPlayerSkill(player) end)
        if player:getHandcardNum() < #skills then
          player:drawCards(#skills - player:getHandcardNum(), self.name)
        end
      end
    else
      local skills = table.filter(target.player_skills, function(s) return not s:isPlayerSkill(player) end)
      if player:getHandcardNum() < #skills then
        player:drawCards(#skills - player:getHandcardNum(), self.name)
      end
    end
  end,

  refresh_events = {fk.PreCardUse},
  can_refresh = function(self, event, target, player, data)
    local mark = player:getTableMark("@tey__cangrong")
    return target == player and data.card.type == Card.TypeBasic and player:hasSkill(self.name)
    and not table.contains(mark, data.card:getSuitString(true)) 
  end,
  on_refresh = function(self, event, target, player, data)
    data.extraUse = true
  end,
}
local tey__cangrong_targetmod = fk.CreateTargetModSkill{
  name = "#tey__cangrong_targetmod",
  bypass_times = function(self, player, skill, scope, card)
    local mark = player:getTableMark("@tey__cangrong")
    return card and not table.contains(mark, card:getSuitString(true)) and player:hasSkill(tey__cangrong.name) and card.type == Card.TypeBasic
  end,
  bypass_distances = function(self, player, skill, card, to)
    local mark = player:getTableMark("@tey__cangrong")
    return card and not table.contains(mark, card:getSuitString(true)) and player:hasSkill(tey__cangrong.name) and card.type == Card.TypeBasic
  end,
}
local tey__baoju = fk.CreateTriggerSkill{
  name = "tey__baoju",
  events = {fk.HpChanged},
  can_trigger = function(self, event, target, player, data)
    local banner = player.room:getBanner("@$natlan_weapons_destructed")
    if banner ~= nil then
      local skills = {}
      for _, id in ipairs(banner) do
        local card = Fk:getCardById(id)---@type EquipCard
        if card.type == Card.TypeEquip then
          local equipSkills = card:getEquipSkills(player)
          if #equipSkills > 0 and not table.contains(player.player_skills, equipSkills) then
            for _, s in ipairs(equipSkills) do
              table.insertIfNeed(skills, s.name)
            end
          end
        end
     end
     return target == player and player:hasSkill(self) and banner ~= nil and #skills > 0
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local banner = player.room:getBanner("@$natlan_weapons_destructed")
    if banner ~= nil then
      local skills = {}
      for _, id in ipairs(banner) do
        local card = Fk:getCardById(id)---@type EquipCard
        if card.type == Card.TypeEquip then
          local equipSkills = card:getEquipSkills(player)
          if #equipSkills > 0 and not table.contains(player.player_skills, equipSkills) then
            for _, s in ipairs(equipSkills) do
              table.insertIfNeed(skills, s.name)
            end
          end
        end
      end
     local toget = room:askForChoices(player, skills, 1, 1, self.name, "#tey__baoju-get", false)
     if #toget > 0 then
       room:addTableMarkIfNeed(player, "@$tey__baoju", toget)
       room:handleAddLoseSkills(player, table.concat(toget, "|"), self.name)
     end
    end
  end,

  refresh_events = {fk.EventPhaseChanging}, --暗巷的技能没法在卡牌包加载，只能耦合到希诺宁本体了
  can_refresh = function(self, event, target, player, data)
    return player == target and data.to == Player.Discard and target:getMark("@@alley_hunter") == true
  end,
  on_refresh = function(self, event, target, player, data)
    target.room:setPlayerMark(target, "@@alley_hunter", 0)
    target:skip(data.to)
    return true
  end,
}
local tey__baoju_trigger = fk.CreateTriggerSkill{ --耦合暗巷的破隐效果
  name = "#tey__baoju_trigger",
  frequency = Skill.Compulsory,
  events = {"fk.GeneralAppeared"},
  can_trigger = function (self, event, target, player, data)
    local effect = false
    for _, id in ipairs(player:getCardIds("e")) do
      local card = Fk:getCardById(id)
      if card.name == "alley_hunter" then
        if card.equip_skill:isEffectable(player)  then
          effect = true
        end
      end
    end
    if target == player and effect then
      local turn_event = player.room.logic:getCurrentEvent():findParent(GameEvent.Turn)
      if turn_event == nil then return end
      local to = turn_event.data[1]
      return to ~= player and player:getHandcardNum() ~= 2
    end
  end,
  on_use = function (self, event, target, player, data)
    local room = player.room
    if player:getHandcardNum() < 2 then
      player:drawCards(2 - player:getHandcardNum(), self.name)
    elseif player:getHandcardNum() > 2 then
      room:askForDiscard(player, player:getHandcardNum() - 2, player:getHandcardNum() - 2, false, self.name, false)
    end
  end,
}

tey__cangrong:addRelatedSkill(tey__cangrong_targetmod)
tey__baoju:addRelatedSkill(tey__baoju_trigger)
Xilonen:addSkill(tey__cangrong)
Xilonen:addSkill(tey__baoju)

Fk:loadTranslationTable{
  ["tey__Xilonen"] = "希诺宁", 
  ["#tey__Xilonen"] = "焮火铸魂",
  ["cv:tey__Xilonen"] = "弭洋",
  ["illustrator:tey__Xilonen"] = "ゆとりこ",
  ["designer:tey__Xilonen"] = "幽蝶化烬",

  ["tey__cangrong"] = "苍熔",
  [":tey__cangrong"] = "锁定技，你使用未记录过花色的基本牌无距离与次数限制，使用后记录花色（记录四个后重置）并选择一项：将一张花色相同的"..
  "<a href='natlan_weapons_href'>纳塔角色武器牌</a>置于场上装备区；或将手牌数摸至装备技能数。",
  ["tey__baoju"] = "豹炬",
  [":tey__baoju"] = "锁定技，你体力值变化后，若小于本局销毁过的<a href='natlan_weapons_href'>纳塔武器牌</a>数量，你获得其中一张的技能。",

  ["@tey__cangrong"] = "苍熔",
  ["@$tey__baoju"] = "豹炬",
  ["#tey__cangrong_place"] = "苍熔：你可以将一张纳塔武器牌置于场上（置入装备区），取消则将手牌摸至装备技能数。",
  ["#tey__baoju-get"] = "豹炬：请选择两个纳塔武器牌的技能获得之。",
  ["#tey__baoju_trigger"] = "暗巷猎手", --耦合暗巷的破隐效果

  ["$tey__cangrong1"] = "",
  ["$tey__cangrong2"] = "",
  ["$tey__baoju1"] = "",
  ["$tey__baoju2"] = "",
  ["~tey__Xilonen"] = "…",
} 

--skill:技能本体
--player:玩家
--<br>筛选被缄朝封锁的技能函数
local jianchaoCheck = function(skill, player)
  local that = Fk:translate(skill.name)
  local noNameMatch = true
  local noDescMatch = true
  for _, otherSkill in ipairs(player.player_skills) do
    if otherSkill.visible and otherSkill ~= skill and not otherSkill:isEquipmentSkill(player) then
      local name = Fk:translate(otherSkill.name)
      local str = Fk:translate(":"..otherSkill.name)
      if string.find(name, ""..that.."") then
        noNameMatch = false
        break
      end
      if string.find(str, ""..that.."") then
        noDescMatch = false
        break
      end
      local href = str:match("<a%s+href%s*=%s*'([^']*)'")
      if href ~= nil then
        local hrefname = Fk:translate(href)
        local hrefstr = ":"..href
        if string.find(hrefname, ""..that.."") then
          noNameMatch = false
          break
        end
        if string.find(hrefstr, ""..that.."") then
          noDescMatch = false
          break
        end
      end
    end
  end
  if noNameMatch and noDescMatch then
    return true
  end
end

local tey__jianchao = fk.CreateInvaliditySkill{
  name = "tey__jianchao",
  invalidity_func = function(self, from, skill)
    if skill:isPlayerSkill(from) and not table.contains(Fk.generals[from.general]:getSkillNameList(true), skill.name) and 
    (from.deputyGeneral == "" or (from.deputyGeneral ~= "" and not table.contains(Fk.generals[from.deputyGeneral]:getSkillNameList(true), skill.name))) and
    table.find(Fk:currentRoom().alive_players, function (p) return p:hasSkill(self.name) end) then
      return jianchaoCheck(skill, from)
    end
  end
}
RaidenShogun:addSkill(tey__jianchao)
tey__jianchao.permanent_skill = true

local tey__sheye = fk.CreateTriggerSkill{
  name = "tey__sheye",
  anim_type = "offensive",
  events = {fk.CardUsing, fk.CardResponding},
  can_trigger = function(self, event, target, player, data)
    local mark = player:getTableMark("@tey__sheye")
    return player:hasSkill(self) and #mark > 0 and data.card.type == Card.TypeBasic and target == player
  end,
  on_cost = function(self, event, target, player, data)
    self.cost_data = nil
    local room = player.room
    local mark = player:getTableMark("@tey__sheye")
    local choices = {}
    if table.contains(mark, "①") then
      table.insertIfNeed(choices, "tey__sheye_transfer")
    end
    if table.contains(mark, "②") and not player:isRemoved() then
      table.insertIfNeed(choices, "tey__sheye_removed")
    end
    if table.contains(mark, "③") and not player.chained then
      table.insertIfNeed(choices, "tey__sheye_shenzhu")
    end
      table.insertIfNeed(choices, "cancel")

    local choice = room:askForChoice(player, choices, self.name)
    if choice == "cancel" then
      return false
    else
      self.cost_data = choice
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    if self.cost_data == "tey__sheye_transfer" then
      room:removeTableMark(player, "@tey__sheye", "①")
      local playerlist = {}
      for _, pid in ipairs(room:getAllPlayers()) do
        for _, s in ipairs(pid.player_skills) do
          if not s:isEquipmentSkill(pid) and s.visible and not table.contains(Fk.generals[pid.general]:getSkillNameList(true), s.name)
          and (pid.deputyGeneral == "" or (pid.deputyGeneral ~= "" and not table.contains(Fk.generals[pid.deputyGeneral]:getSkillNameList(true), s.name))) 
          and jianchaoCheck(s, pid) then
            table.insertIfNeed(playerlist, pid.id)
          end
          if s.name == "tey__jianchao" then
            table.insertIfNeed(playerlist, pid.id)
          end
        end
      end
      if #playerlist < 1 then return end
      local tos = player.room:askForChoosePlayers(player, playerlist, 1, 1, "#tey__sheye_transfer-choose", self.name, false)
      if #tos > 0 then
        local pid = room:getPlayerById(tos[1])
        local skillslist = table.filter(pid.player_skills, function(s) 
          return s.name == "tey__jianchao" or (not s:isEquipmentSkill(pid) and s.visible and not table.contains(Fk.generals[pid.general]:getSkillNameList(true), s.name)
        and (pid.deputyGeneral == "" or (pid.deputyGeneral ~= "" and not table.contains(Fk.generals[pid.deputyGeneral]:getSkillNameList(true), s.name)))) 
          and jianchaoCheck(s, pid) end)
        local skills = table.map(skillslist, function(s) return s.name end)
        local to_delete = room:askForChoices(player, skills, 1, 1, self.name, "#tey__sheye_transferskill-choose", false, false, skills)
        if #to_delete > 0 then
          local playerlists = table.map(table.filter(room:getAlivePlayers(), function(p) return p ~= pid end), Util.IdMapper)
          if #playerlists < 1 then return end
          local toss = player.room:askForChoosePlayers(player, playerlists, 1, 1, "#tey__sheye_transferto-choose", self.name, false)
          if #toss > 0 then
            local pidd = room:getPlayerById(toss[1])
            room:handleAddLoseSkills(pid, "-"..table.concat(to_delete, "|-"))
            room:handleAddLoseSkills(pidd, ""..table.concat(to_delete, "|-"))
          end
        end
      end
    elseif self.cost_data == "tey__sheye_removed" then
      player:setChainState(false)
      if not player.dead then
        room:removeTableMark(player, "@tey__sheye", "②")
        room:setPlayerMark(player, "@@tey__sheye_removed-turn", 1)
        room:setPlayerMark(player, MarkEnum.PlayerRemoved .. "-turn", 1)
        room:handleAddLoseSkills(player, "#Removed__hp|#Removed__prohibit", nil, false, true)
      --room.logic:trigger("fk.RemoveStateChanged", player, nil)
      end
    elseif self.cost_data == "tey__sheye_shenzhu" then
      room:removeTableMark(player, "@tey__sheye", "③")
      player:setChainState(true)
      if not player.dead then
        for loop = 0, 1100, 1 do
          local naming = loop == 0 and "tey__shenzhu" or "tey"..loop.."__shenzhu"
          if not table.find(room:getAllPlayers(), function (pid) return pid:hasSkill(naming, true, true) end) then
            room:handleAddLoseSkills(player, naming)
            break
          end
        end
      end
    end
    --[[if not player.dead then
      player:drawCards(1, self.name) 
    local throws = table.filter(player:getCardIds("hej"), function(id) return not player:prohibitDiscard(Fk:getCardById(id)) end)
      if #throws == 0 then return end
      local cards = room:askForCard(player, 1, 1, true, self.name, false, tostring(Exppattern{ id = throws }), "#tey__sheye-discard", player:getCardIds("j"))
      if #cards > 0 then
        room:throwCard(cards, self.name, player, player)
      end
    end]]
  end,

  refresh_events = {fk.RoundStart},
  can_refresh = function (self, event, target, player, data)
    return player:hasSkill(self, true)
  end,
  on_refresh = function (self, event, target, player, data)
    player.room:setPlayerMark(player, "@tey__sheye", {"①", "②", "③"})
  end,

  on_acquire = function (self, player, is_start)
    player.room:setPlayerMark(player, "@tey__sheye", {"①", "②", "③"})
  end,

  on_lose = function (self, player, is_death)
    player.room:setPlayerMark(player, "@tey__sheye", 0)
  end,
}
RaidenShogun:addSkill(tey__sheye)

local RemovedProhibit = fk.CreateProhibitSkill{
  name = "#Removed__prohibit",
  mute = true,
  prohibit_use = function(self, player, card)
    return player:getMark("@@tey__sheye_removed-turn") ~= 0
  end,
  is_prohibited = function(self, from, to, card)
    return to:getMark("@@tey__sheye_removed-turn") ~= 0
  end,
}
local RemovedHp = fk.CreateTriggerSkill{
  name = "#Removed__hp",
  mute = true,
  events = {fk.HpChanged, fk.BeforeMaxHpChanged, fk.DamageCaused},
  can_trigger = function(self, event, target, player, data)
    return target == player and player:getMark("@@tey__sheye_removed-turn") ~= 0
  end,
  on_cost = Util.TrueFunc,
  on_use = function(self, event, target, player, data)
    if event == fk.DamageCaused then
      data.damage = 0
    end
    return true
  end,
}
Fk:addSkill(RemovedProhibit)
Fk:addSkill(RemovedHp)

local tey__jilei = fk.CreateTriggerSkill{
  name = "tey__jilei$",
  anim_type = "drawcard",
  events = {fk.GameStart, fk.Death, fk.DamageCaused},
  can_trigger = function(self, event, target, player, data)
    if event == fk.GameStart then
      return player:hasSkill(self) 
    elseif event == fk.Death then
      return player:hasSkill(self) and data.damage and data.damage.from == player
    elseif event == fk.DamageCaused then
      return player:hasSkill(self) and target == player and player:getMark("@tey__jilei_dmg") > 0
    end
  end,
  on_cost = Util.TrueFunc,
  on_use = function(self, event, target, player, data)
    local room = player.room
    if event == fk.GameStart or event == fk.Death then
      for _, p in ipairs(room:getAllPlayers()) do
        if not p.dead then
          for loop = 0, 1100, 1 do
            local naming = loop == 0 and "tey__shenzhu" or "tey"..loop.."__shenzhu"
            if not table.find(room:getAllPlayers(), function (pid) return pid:hasSkill(naming, true, true) end) then
              room:handleAddLoseSkills(p, naming)
              break
            end
          end
        end
      end
    elseif event == fk.DamageCaused then
      data.damage = data.damage + player:getMark("@tey__jilei_dmg")
      room:setPlayerMark(player, "@tey__jilei_dmg", 0)
    end
  end,
}

RaidenShogun:addSkill(tey__jilei)
tey__jilei.permanent_skill = true

Fk:loadTranslationTable{
  ["tey__RaidenShogun"] = "雷电将军", 
  ["#tey__RaidenShogun"] = "一心净土",
  ["cv:tey__RaidenShogun"] = "菊花花",
  ["illustrator:tey__RaidenShogun"] = "haohaomaster",
  ["designer:tey__RaidenShogun"] = "幽蝶化烬",

  ["tey__jianchao"] = "缄朝",
  [":tey__jianchao"] = "持恒技，若一名角色衍生技能的名称不存在于其其他技能的<a href='tey__jianchao_desc-href'>名称或描述</a>中，此衍生技能失效。",
  ["tey__sheye"] = "慑野",
  [":tey__sheye"] = "每轮每项限一次，你使用或打出基本牌后，可以选择一项：转移“缄朝”或一个因之失效的技能；重置，本回合移出游戏；横置，获得一个“神祝”。",
  ["tey__jilei"] = "殛雷",
  [":tey__jilei"] = "主公技，持恒技，游戏开始时或你杀死角色后，所有角色获得一个“神祝”。每三次有角色失去“神祝”后，你下次造成的伤害+1（至多+3）。",
  ["tey__shenzhu"] = "神祝",
  [":tey__shenzhu"] = "你获得此技能时摸一张牌。你可以失去此技能视为使用雷【杀】且有衍生技能的角色不能响应。",

  ["@@tey__sheye_removed-turn"] = "移出游戏",
  ["tey__jianchao_desc-href"] = "名称：技能名；描述：技能描述，包含注释和超链接的说明性文字",
  ["tey__sheye_transfer"] = "转移特定技能",
  ["tey__sheye_removed"] = "本回合移出游戏",
  ["tey__sheye_shenzhu"] = "横置并获得技能",
  ["#tey__sheye_transfer-choose"] = "慑野：请选择一名角色，转移其“缄朝”或一个因之失效的技能！",
  ["#tey__sheye_transferskill-choose"] = "慑野：请选择一个技能转移！",
  ["#tey__sheye_transferto-choose"] = "慑野：请选择一名角色，获得先前选择的技能！",
  ["#tey__sheye-discard"] = "慑野：请弃置你区域内的一张牌！",
  ["@tey__sheye"] = "慑野",
  ["#tey__shenzhu_trigger"] = "神祝",
  ["@tey__jilei_dmg"] = "<font color=\"purple\">愿力</font>",

  ["$tey__jianchao1"] = "浮世景色百千年依旧，人之在世却如白露与泡影。虚无。",
  ["$tey__jianchao2"] = "徒然无事，对砚枯坐。哼。",
  ["$tey__sheye1"] = "此世最为殊胜最为恐怖的雷霆化身就站在你身边。",
  ["$tey__sheye2"] = "天晴也并不能掩盖雷霆的威光。",
  ["$tey__jilei1"] = "此刻，寂灭之时！",
  ["$tey__jilei2"] = "稻光，亦是永恒！",
  ["$tey__shenzhu1"] = "将军她构造还挺结实的，坏了还能替换呢。",
  ["$tey__shenzhu2"] = "此身诞生的意义，就是承受磨损。",
  ["~tey__RaidenShogun"] = "雷鸣，将歇…",
} 

local tey__shenzhu_trigger = fk.CreateTriggerSkill{
  name = "#tey__shenzhu_trigger",
  anim_type = "offensive",
  mute = true,
  global = true,
  events = {fk.CardUsing},
  can_trigger = function(self, event, target, player, data)
    if data.card.trueName == "slash" then
      --[[for loop = 0, 1100, 1 do
        if loop == 0 then
          return table.contains(data.card.skillNames, "tey__shenzhu")
        else
          return table.contains(data.card.skillNames, "tey"..loop.."__shenzhu")
        end
      end]]
      return table.contains(data.card.skillNames, "tey__shenzhu")
    end
  end,
  on_cost = Util.TrueFunc,
  on_use = function(self, event, target, player, data)
    data.disresponsiveList = data.disresponsiveList or {}
    for _, p in ipairs(player.room.alive_players) do
      for _, s in ipairs(p.player_skills) do
        if not s:isEquipmentSkill(p) and s.visible and not table.contains(Fk.generals[p.general]:getSkillNameList(true), s.name)
        and (p.deputyGeneral == "" or (p.deputyGeneral ~= "" and not table.contains(Fk.generals[p.deputyGeneral]:getSkillNameList(true), s.name))) then
          table.insertIfNeed(data.disresponsiveList, p.id)
        end
      end
    end
  end,
}

  --让神祝最后加载，强行规定技能顺序
for loop = 0, 1100, 1 do --千手白眼
  local tey__shenzhu = fk.CreateViewAsSkill{
    name = loop == 0 and "tey__shenzhu" or "tey"..loop.."__shenzhu",
    anim_type = "offensive",
    mute = true,
    card_num = 0,
    pattern = "slash",
    card_filter = Util.FalseFunc,
    view_as = function(self, cards)
      local c = Fk:cloneCard("thunder__slash")
      c.skillName = "tey__shenzhu"
      return c
    end,
    before_use = function(self, player, use)
      player:broadcastSkillInvoke("tey__shenzhu")
      player.room:notifySkillInvoked(player, "tey__shenzhu", "offensive")
      player.room:handleAddLoseSkills(player, "-"..self.name)
    end,
    enabled_at_response = function(self, player, response)
      local pat = Fk.currentResponsePattern
      return not response and pat and Exppattern:Parse(pat):matchExp("slash")
    end,
    on_acquire = function (self, player, is_start)
      if player:hasSkill(self) then
        player:drawCards(1, self.name)
      end
    end,
    on_lose = function (self, player, is_death)
      local room = player.room
      for _, p in ipairs(player.room:getAllPlayers()) do
        if p:hasSkill("tey__jilei", true) then
          room:addPlayerMark(p, "tey__jilei_times", 1)
          if p:getMark("tey__jilei_times") % 3 == 0 and p:getMark("@tey__jilei_dmg") < 3 then
            room:addPlayerMark(p, "@tey__jilei_dmg", 1)
          end
        end
      end
    end,
  }
  if loop > 0 then
    --tey__shenzhu:addRelatedSkill(tey__shenzhu_trigger)
    Fk:addSkill(tey__shenzhu)
  else
    Fk:addSkill(tey__shenzhu_trigger)
    --tey__shenzhu:addRelatedSkill(tey__shenzhu_trigger)
    RaidenShogun:addRelatedSkill(tey__shenzhu)
  end
  Fk:loadTranslationTable{
    ["tey"..loop.."__shenzhu"] = "神祝",
    [":tey"..loop.."__shenzhu"] = "你获得此技能时摸一张牌。你可以失去此技能视为使用雷【杀】且有衍生技能的角色不能响应。",
  }
end

if not Fk.skills["hidden_skill&"] then
local hidden_skill = fk.CreateTriggerSkill{
  name = "hidden_skill&",
  priority = 0.001,
  mute = true,
  events = {fk.HpChanged, fk.TurnStart, fk.BeforeMaxHpChanged},
  can_trigger = function(self, event, target, player, data)
    if target == player and not player.dead and
    (player:getMark("__hidden_general") ~= 0 or player:getMark("__hidden_deputy") ~= 0) then
      if event == fk.HpChanged then
        return data.num < 0
      else
        return true
      end
    end
  end,
  on_cost = Util.TrueFunc,
  on_use = function(self, event, target, player, data)
    local room = player.room
    if event == fk.BeforeMaxHpChanged then
      return true
    else
      room:handleAddLoseSkills(player, "-"..self.name, nil, false, true)
      if Fk.generals[player:getMark("__hidden_general")] then
        player.general = player:getMark("__hidden_general")
      end
      if Fk.generals[player:getMark("__hidden_deputy")] then
        player.deputyGeneral = player:getMark("__hidden_deputy")
      end
      room:setPlayerMark(player, "__hidden_general", 0)
      room:setPlayerMark(player, "__hidden_deputy", 0)
      local general = Fk.generals[player.general]
      local deputy = Fk.generals[player.deputyGeneral]
      player.gender = general.gender
      player.kingdom = general.kingdom
      room:broadcastProperty(player, "gender")
      room:broadcastProperty(player, "general")
      room:broadcastProperty(player, "deputyGeneral")
      room:askForChooseKingdom({player})
      room:broadcastProperty(player, "kingdom")

      if player:getMark("__hidden_record") ~= 0 then
        player.maxHp = player:getMark("__hidden_record").maxHp
        player.hp = player:getMark("__hidden_record").hp
      else
        player.maxHp = player:getGeneralMaxHp()
        player.hp = deputy and math.floor((deputy.hp + general.hp) / 2) or general.hp
      end
      player.shield = math.min(general.shield + (deputy and deputy.shield or 0), 5)
      if player:getMark("__hidden_record") ~= 0 then
        room:setPlayerMark(player, "__hidden_record", 0)
      else
        local changer = Fk.game_modes[room.settings.gameMode]:getAdjustedProperty(player)
        if changer then
          for key, value in pairs(changer) do
            player[key] = value
          end
        end
      end
      room:broadcastProperty(player, "maxHp")
      room:broadcastProperty(player, "hp")
      room:broadcastProperty(player, "shield")

      local lordBuff = player.role == "lord" and player.role_shown == true and #room.players > 4
      local skills = general:getSkillNameList(lordBuff)
      if deputy then
        table.insertTable(skills, deputy:getSkillNameList(lordBuff))
      end
      skills = table.filter(skills, function (s)
        local skill = Fk.skills[s]
        return skill and (#skill.attachedKingdom == 0 or table.contains(skill.attachedKingdom, player.kingdom))
      end)
      if #skills > 0 then
        room:handleAddLoseSkills(player, table.concat(skills, "|"), nil, false)
      end

      room:sendLog{ type = "#RevealGeneral", from = player.id, arg =  "mainGeneral", arg2 = general.name }
      local event_data = {["m"] = general}
      if deputy then
        room:sendLog{ type = "#RevealGeneral", from = player.id, arg =  "deputyGeneral", arg2 = deputy.name }
        event_data["d"] = deputy.name
      end
      room.logic:trigger("fk.GeneralAppeared", player, event_data)
    end
  end,
}
  Fatui:addSkill(hidden_skill)
else
  Fatui:addSkill("hidden_skill&")
end

Fk:loadTranslationTable{
  ["tey__Fatui"] = "愚人众", 
  ["#tey__Fatui"] = "尘烟暗幕",
  ["cv:tey__Fatui"] = "无",
  ["illustrator:tey__Fatui"] = "dreamday",
  ["designer:tey__Fatui"] = "无",

  ["hidden_skill&"] = "隐匿",
  [":hidden_skill&"] = "若你为隐匿将，防止你改变体力上限。当你扣减体力后，或你回合开始时，你解除隐匿状态。",
} 
 --[[
 local tey__yifu = fk.CreateTriggerSkill{
  name = "tey__yifu",
  anim_type = "offensive",
  events = {fk.DamageCaused},
  can_trigger = function(self, event, target, player, data)
    if not data.card or not U.isPureCard(data.card) then
    return player:hasSkill(self) and not target.dead and 
      player:usedSkillTimes(self.name, Player.HistoryTurn) == 0 and target:getMark("@@tey__yifu_already") == 0
    end
  end, 
  on_cost = function(self, event, target, player, data)
    local room = player.room
    local card = room:askForDiscard(player, 1, 1, true, self.name, true, ".", "#tey__yifu-invoke:", true)
    if #card > 0 then
      self.cost_data = card[1]
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    player.room:throwCard({self.cost_data}, self.name, player, player)
    if target ~= player then player.room:setPlayerMark(target, "@@tey__yifu_already", 1) end
    data.damage = data.damage + 1
    local choices = {"cancel","draw2"}
    if player:getMark("@@tey__weiming_level3") == 0 then table.insert(choices, "tey__weiming_levelup") end
    if #choices < 1 then return false end
    local choice = player.room:askForChoice(player, choices, self.name, "#tey__yifu-choice:")
    if choice == "draw2" then
      player:drawCards(2, self.name)
    elseif choice == "tey__weiming_levelup" then
      if player:getMark("@@tey__weiming_level2") == 0 then
        player.room:setPlayerMark(player, "@@tey__weiming_level2", 1)
      else
        player.room:setPlayerMark(player, "@@tey__weiming_level2", 0)
        player.room:setPlayerMark(player, "@@tey__weiming_level3", 1)
      end
    elseif choice == "cancel" then
      return false 
      end
  end,
}

local tey__weiming = fk.CreateTriggerSkill{
  name = "tey__weiming",
  events = {fk.EventPhaseStart},
  can_trigger = function(self, event, target, player, data)
    if target == player or player:getMark("@@tey__weiming_level3") == 1 then
    if player:hasSkill(self) and target.phase == Player.Finish then
      local x = player:getMark("@tey__weiming-turn")
      if x == 0 then return false end
      if type(x) == "string" then x = 0 end
      return x ~= player:getHandcardNum()
    end
   end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local x = player:getMark("@tey__weiming-turn")
    if x == 0 then return false end
    if player:getMark("@@tey__weiming_level2") == 1 or player:getMark("@@tey__weiming_level3") == 1 then
    local _, dat = room:askForUseActiveSkill(player, "tey__weiming_viewas", "#tey__weiming-ask", true)
    if dat then
    local card = Fk.skills["tey__weiming_viewas"]:viewAs(dat.cards)
    local use = {
      from = player.id,
      tos = table.map(dat.targets, function(id) return {id} end),
      card = card,
      extraUse = true,}
      room:useCard(use)
    end
  else
    local _, dat1 = room:askForUseActiveSkill(player, "tey__weiming_viewas2", "#tey__weiming-askless", true)
    if dat1 then
    local card = Fk.skills["tey__weiming_viewas2"]:viewAs(dat1.cards)
    local use = {
      from = player.id,
      tos = table.map(dat1.targets, function(id) return {id} end),
      card = card,
      extraUse = true,}
      room:useCard(use)
    end
    end
  end,

  refresh_events = {fk.TurnStart},
  can_refresh = function (self, event, target, player, data)
    return player:hasSkill(self, true)
  end,
  on_refresh = function (self, event, target, player, data)
    local x = player:getHandcardNum()
    player.room:setPlayerMark(player, "@tey__weiming-turn", x > 0 and x or "0")
  end,
}
local tey__weiming_viewas = fk.CreateViewAsSkill{
  name = "tey__weiming_viewas",
  card_filter = function (self, to_select, selected)
    return #selected == 0
  end,
  interaction = function()
    local all_names, names = Self:getTableMark("@$tey__weiming"), {}
    for _, name in ipairs(all_names) do
      local to_use = Fk:cloneCard(name)
      to_use.skillName = "tey_weiming"
      if to_use.skill:canUse(Self, to_use) and not Self:prohibitUse(to_use) then
        table.insertIfNeed(names, name)
      end
    end
    if #names == 0 then return end
    return UI.ComboBox {choices = names}
  end,
  view_as = function(self, cards)
    if #cards ~= 1 or not self.interaction.data then return end
    local card = Fk:cloneCard(self.interaction.data)
    card:addSubcard(cards[1])
    card.skillName = self.name
    return card
  end,
  before_use = function(self, player, useData)
    useData.extraUse = true
    local names = player:getTableMark("@$tey__weiming")
    if table.removeOne(names, useData.card.name) then
      player.room:setPlayerMark(player, "@$tey__weiming", names)
    end
  end,

  on_lose = function (self, player)
    player.room:setPlayerMark(player, "@$tey__weiming", 0)
  end,
}
local tey__weiming_trigger = fk.CreateTriggerSkill{
  name = "#tey__weiming_trigger",
  events = {fk.AfterCardsMove},
  mute = true,
  can_trigger = function(self, event, target, player, data)
    for _, move in ipairs(data) do
      if move.fromArea == Card.DiscardPile or move.toArea == Card.DiscardPile then
        return player:hasSkill(tey__weiming)
      end
    end
  end,
  on_cost = Util.TrueFunc,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local names = {}
    for _, id in ipairs(room.discard_pile) do
      local card = Fk:getCardById(id)
      if card.type == Card.TypeBasic or card:isCommonTrick() then
        table.insertIfNeed(names, card.name)
      end
    end
    room:setPlayerMark(player, "@$tey__weiming", #names > 0 and names or 0)
  end,
}
local tey__weiming_viewas2 = fk.CreateViewAsSkill{
  name = "tey__weiming_viewas2",
  card_filter = function (self, to_select, selected)
    return #selected == 0
  end,
  interaction = function()
    local all_names, names = Self:getTableMark("tey__weiming_cards-turn"), {}
    for _, ids in ipairs(all_names) do
      local name = Fk:getCardById(ids).name 
      local to_use = Fk:cloneCard(name)
      to_use.skillName = "tey_weiming"
      if to_use.skill:canUse(Self, to_use) and not Self:prohibitUse(to_use) then
        table.insertIfNeed(names, name)
      end
    end
    if #names == 0 then return end
    return UI.ComboBox {choices = names}
  end,
  view_as = function(self, cards)
    if #cards ~= 1 or not self.interaction.data then return end
    local card = Fk:cloneCard(self.interaction.data)
    card:addSubcard(cards[1])
    card.skillName = self.name
    return card
  end,
  before_use = function(self, player, useData)
    useData.extraUse = true
    local names = player:getTableMark("tey__weiming_cards-turn")
    if table.removeOne(names, useData.card.name) then
      player.room:setPlayerMark(player, "tey__weiming_cards-turn", names)
    end
  end,

  on_lose = function (self, player)
    player.room:setPlayerMark(player, "@$tey__weiming", 0)
  end,
}
local tey__weiming_refresh = fk.CreateTriggerSkill{
  name = "#tey__weiming_refresh",

  refresh_events = {fk.AfterCardsMove, fk.AfterDrawPileShuffle},
  can_refresh = function(self, event, target, player, data)
    return player:hasSkill(tey__weiming)
  end,
  on_refresh = function(self, event, target, player, data)
    local room = player.room
    if event == fk.AfterCardsMove then
      local ids = player:getTableMark("tey__weiming_cards-turn")
      for _, move in ipairs(data) do
        if move.toArea == Card.DiscardPile then
          for _, info in ipairs(move.moveInfo) do
            table.insertIfNeed(ids, info.cardId)
          end
        end
      end
      ids = table.filter(ids, function (id) 
        return room:getCardArea(id) == Card.DiscardPile and 
          (Fk:getCardById(id).type == Card.TypeBasic or Fk:getCardById(id):isCommonTrick())
      end)
      room:setPlayerMark(player, "tey__weiming_cards-turn", ids)
    elseif event == fk.AfterDrawPileShuffle then
      room:setPlayerMark(player, "tey__weiming_cards-turn", 0)
    end
  end,
}

local tey__huji = fk.CreateTriggerSkill{
  name = "tey__huji",
  frequency = Skill.Wake,
  anim_type = "offensive",
  events = {fk.EventPhaseStart},
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(self) and player:usedSkillTimes(self.name, Player.HistoryGame) == 0
    and target.phase == Player.Finish 
  end,
  can_wake = function(self, event, target, player, data)
    return #player.room.alive_players < 4 and player:getMark("@@tey__weiming_level3") == 1
  end,
  on_use = function(self, event, target, player, data)
    player.room:changeMaxHp(player, 1)
    player.room:recover({
      who = player,
      num = player:getLostHp(),
      recoverBy = player,
      skillName = self.name
    })
    player.room:handleAddLoseSkills(player, "ty__xuewei")
  end,
}

Fk:addSkill(tey__weiming_viewas)
Fk:addSkill(tey__weiming_viewas2)
tey__weiming:addRelatedSkill(tey__weiming_trigger)
tey__weiming:addRelatedSkill(tey__weiming_refresh)
SPShenhe:addSkill(tey__yifu)
SPShenhe:addSkill(tey__weiming)
SPShenhe:addSkill(tey__huji)
SPShenhe:addRelatedSkill("ty__xuewei")
]]

return extension